Skip to content

Commit

Permalink
powerpc/pseries: fix possible memory leak in ibmebus_bus_init()
Browse files Browse the repository at this point in the history
[ Upstream commit afda85b ]

If device_register() returns error in ibmebus_bus_init(), name of kobject
which is allocated in dev_set_name() called in device_add() is leaked.

As comment of device_add() says, it should call put_device() to drop
the reference count that was set in device_initialize() when it fails,
so the name can be freed in kobject_cleanup().

Signed-off-by: ruanjinjie <ruanjinjie@huawei.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20221110011929.3709774-1-ruanjinjie@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
ruanjinjie authored and gregkh committed Sep 23, 2023
1 parent ee378f4 commit 96f27ff
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions arch/powerpc/platforms/pseries/ibmebus.c
Expand Up @@ -455,6 +455,7 @@ static int __init ibmebus_bus_init(void)
if (err) {
printk(KERN_WARNING "%s: device_register returned %i\n",
__func__, err);
put_device(&ibmebus_bus_device);
bus_unregister(&ibmebus_bus_type);

return err;
Expand Down

0 comments on commit 96f27ff

Please sign in to comment.