Skip to content

Commit ef6eadb

Browse files
jhovoldgregkh
authored andcommitted
powerpc/ibmebus: Fix device reference leaks in sysfs interface
commit fe0f3168169f7c34c29b0cf0c489f126a7f29643 upstream. Make sure to drop any reference taken by bus_find_device() in the sysfs callbacks that are used to create and destroy devices based on device-tree entries. Fixes: 6bccf75 ("[POWERPC] ibmebus: dynamic addition/removal of adapters, some code cleanup") Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 488e7b2 commit ef6eadb

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

arch/powerpc/kernel/ibmebus.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,18 @@ static ssize_t ibmebus_store_probe(struct bus_type *bus,
266266
const char *buf, size_t count)
267267
{
268268
struct device_node *dn = NULL;
269+
struct device *dev;
269270
char *path;
270271
ssize_t rc = 0;
271272

272273
path = ibmebus_chomp(buf, count);
273274
if (!path)
274275
return -ENOMEM;
275276

276-
if (bus_find_device(&ibmebus_bus_type, NULL, path,
277-
ibmebus_match_path)) {
277+
dev = bus_find_device(&ibmebus_bus_type, NULL, path,
278+
ibmebus_match_path);
279+
if (dev) {
280+
put_device(dev);
278281
printk(KERN_WARNING "%s: %s has already been probed\n",
279282
__func__, path);
280283
rc = -EEXIST;
@@ -311,6 +314,7 @@ static ssize_t ibmebus_store_remove(struct bus_type *bus,
311314
if ((dev = bus_find_device(&ibmebus_bus_type, NULL, path,
312315
ibmebus_match_path))) {
313316
of_device_unregister(to_platform_device(dev));
317+
put_device(dev);
314318

315319
kfree(path);
316320
return count;

0 commit comments

Comments
 (0)