From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: ruanjinjie <ruanjinjie@huawei.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Sasha Levin <sashal@kernel.org>,
gregkh@linuxfoundation.org, idryomov@gmail.com,
wei.liu@kernel.org, ira.weiny@intel.com, sfr@canb.auug.org.au,
robh@kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: [PATCH AUTOSEL 6.5 09/11] powerpc/pseries: fix possible memory leak in ibmebus_bus_init()
Date: Fri, 8 Sep 2023 20:22:02 -0400 [thread overview]
Message-ID: <20230909002205.3578068-9-sashal@kernel.org> (raw)
In-Reply-To: <20230909002205.3578068-1-sashal@kernel.org>
From: ruanjinjie <ruanjinjie@huawei.com>
[ Upstream commit afda85b963c12947e298ad85d757e333aa40fd74 ]
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>
---
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 44703f13985bf..969cb9fc960f8 100644
--- a/arch/powerpc/platforms/pseries/ibmebus.c
+++ b/arch/powerpc/platforms/pseries/ibmebus.c
@@ -460,6 +460,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.40.1
next prev parent reply other threads:[~2023-09-09 1:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-09 0:21 [PATCH AUTOSEL 6.5 01/11] fs/jfs: prevent double-free in dbUnmount() after failed jfs_remount() Sasha Levin
2023-09-09 0:21 ` [PATCH AUTOSEL 6.5 02/11] jfs: fix invalid free of JFS_IP(ipimap)->i_imap in diUnmount Sasha Levin
2023-09-09 0:21 ` [PATCH AUTOSEL 6.5 03/11] PCI: Make quirk using inw() depend on HAS_IOPORT Sasha Levin
2023-09-09 0:21 ` [PATCH AUTOSEL 6.5 04/11] ext4: add two helper functions extent_logical_end() and pa_logical_end() Sasha Levin
2023-09-09 0:21 ` [PATCH AUTOSEL 6.5 05/11] ext4: avoid overlapping preallocations due to overflow Sasha Levin
2023-09-09 0:21 ` [PATCH AUTOSEL 6.5 06/11] PCI: dwc: Provide deinit callback for i.MX Sasha Levin
2023-09-09 0:22 ` [PATCH AUTOSEL 6.5 07/11] ARM: 9316/1: hw_breakpoint: fix single-stepping when using bpf_overflow_handler Sasha Levin
2023-09-09 0:22 ` [PATCH AUTOSEL 6.5 08/11] ARM: 9317/1: kexec: Make smp stop calls asynchronous Sasha Levin
2023-09-09 0:22 ` Sasha Levin [this message]
2023-09-09 0:22 ` [PATCH AUTOSEL 6.5 10/11] PCI: vmd: Disable bridge window for domain reset Sasha Levin
2023-09-09 0:22 ` [PATCH AUTOSEL 6.5 11/11] PCI: fu740: Set the number of MSI vectors Sasha Levin
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=20230909002205.3578068-9-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=idryomov@gmail.com \
--cc=ira.weiny@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=robh@kernel.org \
--cc=ruanjinjie@huawei.com \
--cc=sfr@canb.auug.org.au \
--cc=stable@vger.kernel.org \
--cc=wei.liu@kernel.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®