From: ruanjinjie <ruanjinjie@huawei.com> To: <mpe@ellerman.id.au>, <npiggin@gmail.com>, <christophe.leroy@csgroup.eu>, <windhl@126.com>, <linuxppc-dev@lists.ozlabs.org>, <linux-kernel@vger.kernel.org> Cc: <ruanjinjie@huawei.com> Subject: [PATCH] powerpc/pseries: fix possible memory leak in ibmebus_bus_init() Date: Thu, 10 Nov 2022 09:19:29 +0800 [thread overview] Message-ID: <20221110011929.3709774-1-ruanjinjie@huawei.com> (raw) 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> --- arch/powerpc/platforms/pseries/ibmebus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/platforms/pseries/ibmebus.c b/arch/powerpc/platforms/pseries/ibmebus.c index a870cada7acd..ed5fc70b7353 100644 --- a/arch/powerpc/platforms/pseries/ibmebus.c +++ b/arch/powerpc/platforms/pseries/ibmebus.c @@ -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; -- 2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: ruanjinjie <ruanjinjie@huawei.com> To: <mpe@ellerman.id.au>, <npiggin@gmail.com>, <christophe.leroy@csgroup.eu>, <windhl@126.com>, <linuxppc-dev@lists.ozlabs.org>, <linux-kernel@vger.kernel.org> Cc: ruanjinjie@huawei.com Subject: [PATCH] powerpc/pseries: fix possible memory leak in ibmebus_bus_init() Date: Thu, 10 Nov 2022 09:19:29 +0800 [thread overview] Message-ID: <20221110011929.3709774-1-ruanjinjie@huawei.com> (raw) 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> --- arch/powerpc/platforms/pseries/ibmebus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/platforms/pseries/ibmebus.c b/arch/powerpc/platforms/pseries/ibmebus.c index a870cada7acd..ed5fc70b7353 100644 --- a/arch/powerpc/platforms/pseries/ibmebus.c +++ b/arch/powerpc/platforms/pseries/ibmebus.c @@ -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; -- 2.25.1
next reply other threads:[~2022-11-10 1:22 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-10 1:19 ruanjinjie [this message] 2022-11-10 1:19 ` [PATCH] powerpc/pseries: fix possible memory leak in ibmebus_bus_init() ruanjinjie 2023-08-23 11:55 ` Michael Ellerman
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221110011929.3709774-1-ruanjinjie@huawei.com \ --to=ruanjinjie@huawei.com \ --cc=christophe.leroy@csgroup.eu \ --cc=linux-kernel@vger.kernel.org \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=mpe@ellerman.id.au \ --cc=npiggin@gmail.com \ --cc=windhl@126.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.