From: Luis Chamberlain <mcgrof@kernel.org>
To: axboe@kernel.dk, hare@suse.de, hch@infradead.org, wubo40@huawei.com
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Luis Chamberlain <mcgrof@kernel.org>
Subject: [PATCH] block: fix bd_holder_dir kobject_create_and_add() error handling
Date: Thu, 4 Nov 2021 12:29:59 -0700 [thread overview]
Message-ID: <20211104192959.2355827-1-mcgrof@kernel.org> (raw)
Commit 83cbce957446 ("block: add error handling for device_add_disk /
add_disk") added error handling to device_add_disk(), however the goto
label for the bd_holder_dir kobject_create_and_add() failure did not set
the return value correctly, and so we can end up in a situation where
kobject_create_and_add() fails but we report success.
Fixes: 83cbce957446 ("block: add error handling for device_add_disk / add_disk")
Reported-by: Wu Bo <wubo40@huawei.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
block/genhd.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/block/genhd.c b/block/genhd.c
index 2263f7862241..c5392cc24d37 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -472,8 +472,10 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
disk->part0->bd_holder_dir =
kobject_create_and_add("holders", &ddev->kobj);
- if (!disk->part0->bd_holder_dir)
+ if (!disk->part0->bd_holder_dir) {
+ ret = -ENOMEM;
goto out_del_integrity;
+ }
disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj);
if (!disk->slave_dir) {
ret = -ENOMEM;
--
2.33.0
next reply other threads:[~2021-11-04 19:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-04 19:29 Luis Chamberlain [this message]
2021-11-04 19:30 ` [PATCH] block: fix bd_holder_dir kobject_create_and_add() error handling Jens Axboe
2021-11-04 19:31 ` Luis Chamberlain
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=20211104192959.2355827-1-mcgrof@kernel.org \
--to=mcgrof@kernel.org \
--cc=axboe@kernel.dk \
--cc=hare@suse.de \
--cc=hch@infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wubo40@huawei.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: 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