From: Wang Hai <wanghai38@huawei.com>
To: <mb@lightnvm.io>, <axboe@fb.com>, <jg@lightnvm.io>,
<matias@cnexlabs.com>
Cc: <linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<wanghai38@huawei.com>
Subject: [PATCH] lightnvm: pblk: Fix kobject memleak
Date: Tue, 2 Jun 2020 15:17:46 +0800 [thread overview]
Message-ID: <20200602071746.73020-1-wanghai38@huawei.com> (raw)
Currently the error return path from kobject_init_and_add() is not
followed by a call to kobject_put() - which means we are leaking
the kobject.
Fix it by adding a call to kobject_put() in the error path of
kobject_init_and_add().
Fixes: a4bd217b4326 ("lightnvm: physical block device (pblk) target")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
---
drivers/lightnvm/pblk-sysfs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/lightnvm/pblk-sysfs.c b/drivers/lightnvm/pblk-sysfs.c
index 6387302..a8cb89b 100644
--- a/drivers/lightnvm/pblk-sysfs.c
+++ b/drivers/lightnvm/pblk-sysfs.c
@@ -710,6 +710,7 @@ int pblk_sysfs_init(struct gendisk *tdisk)
kobject_get(&parent_dev->kobj),
"%s", "pblk");
if (ret) {
+ kobject_put(&pblk->kobj);
pblk_err(pblk, "could not register\n");
return ret;
}
--
1.8.3.1
reply other threads:[~2020-06-02 7:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20200602071746.73020-1-wanghai38@huawei.com \
--to=wanghai38@huawei.com \
--cc=axboe@fb.com \
--cc=jg@lightnvm.io \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matias@cnexlabs.com \
--cc=mb@lightnvm.io \
/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®