Skip to contentSkip to conversation

md/raid5: missing error code in setup_conf()

PATCH Applied Dan Carpenter 3 participants 3 messages Jul 19, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 md/raid5: missing error code in setup_conf()

Return -ENOMEM if the allocation fails. Don't return success.

Fixes 8fbcba6b999b ("md/raid5: Cleanup setup_conf() error returns")
---
 drivers/md/raid5.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/raid5.c +3 -1
index a7db73d36cc4..f31012357572 100644
@@ -7492,7 +7492,9 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 		goto abort;
 	conf->mddev = mddev;
 
-	if ((conf->stripe_hashtbl = kzalloc(PAGE_SIZE, GFP_KERNEL)) == NULL)
+	ret = -ENOMEM;
+	conf->stripe_hashtbl = kzalloc(PAGE_SIZE, GFP_KERNEL);
+	if (!conf->stripe_hashtbl)
 		goto abort;
 
 	/* We init hash_locks[0] separately to that it can be used
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Dan Carpenter

Return -ENOMEM if the allocation fails. Don't return success.

Fixes 8fbcba6b999b ("md/raid5: Cleanup setup_conf() error returns")

Oops, nice catch.

Thanks,

Logan

Quoted 19 lines
---
 drivers/md/raid5.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/raid5.c +3 -1
index a7db73d36cc4..f31012357572 100644
@@ -7492,7 +7492,9 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 		goto abort;
 	conf->mddev = mddev;
 
-	if ((conf->stripe_hashtbl = kzalloc(PAGE_SIZE, GFP_KERNEL)) == NULL)
+	ret = -ENOMEM;
+	conf->stripe_hashtbl = kzalloc(PAGE_SIZE, GFP_KERNEL);
+	if (!conf->stripe_hashtbl)
 		goto abort;
 
 	/* We init hash_locks[0] separately to that it can be used
maintainer Applied
#2 lore raw
Quoted 4 lines · Logan Gunthorpe

On 2022-07-19 03:48, Dan Carpenter wrote:

Quoted 8 lines
Quoted 4 lines

Return -ENOMEM if the allocation fails. Don't return success.

Fixes 8fbcba6b999b ("md/raid5: Cleanup setup_conf() error returns")

Oops, nice catch.

Applied to md-fixes. Thanks!

Song