* [PATCH] block: fix bd_holder_dir kobject_create_and_add() error handling
@ 2021-11-04 19:29 Luis Chamberlain
2021-11-04 19:30 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: Luis Chamberlain @ 2021-11-04 19:29 UTC (permalink / raw)
To: axboe, hare, hch, wubo40; +Cc: linux-block, linux-kernel, Luis Chamberlain
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] block: fix bd_holder_dir kobject_create_and_add() error handling
2021-11-04 19:29 [PATCH] block: fix bd_holder_dir kobject_create_and_add() error handling Luis Chamberlain
@ 2021-11-04 19:30 ` Jens Axboe
2021-11-04 19:31 ` Luis Chamberlain
0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2021-11-04 19:30 UTC (permalink / raw)
To: Luis Chamberlain, hare, hch, wubo40; +Cc: linux-block, linux-kernel
On 11/4/21 1:29 PM, Luis Chamberlain wrote:
> 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.
I'm just going to fold this one in, as it's top-of-tree.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] block: fix bd_holder_dir kobject_create_and_add() error handling
2021-11-04 19:30 ` Jens Axboe
@ 2021-11-04 19:31 ` Luis Chamberlain
0 siblings, 0 replies; 3+ messages in thread
From: Luis Chamberlain @ 2021-11-04 19:31 UTC (permalink / raw)
To: Jens Axboe; +Cc: hare, hch, wubo40, linux-block, linux-kernel
On Thu, Nov 04, 2021 at 01:30:29PM -0600, Jens Axboe wrote:
> On 11/4/21 1:29 PM, Luis Chamberlain wrote:
> > 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.
>
> I'm just going to fold this one in, as it's top-of-tree.
Makes sense.
Luis
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-04 19:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04 19:29 [PATCH] block: fix bd_holder_dir kobject_create_and_add() error handling Luis Chamberlain
2021-11-04 19:30 ` Jens Axboe
2021-11-04 19:31 ` Luis Chamberlain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).