From: Dan Carpenter Date: Wed, 15 Jan 2025 06:53:52 +0000 (+0300) Subject: md/md-linear: Fix a NULL vs IS_ERR() bug in linear_add() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=62c552070a980363d55a6082b432ebd1cade7a6e;p=users%2Fjedix%2Flinux-maple.git md/md-linear: Fix a NULL vs IS_ERR() bug in linear_add() The linear_conf() returns error pointers, it doesn't return NULL. Update the error checking to match. Fixes: 127186cfb184 ("md: reintroduce md-linear") Signed-off-by: Dan Carpenter Reviewed-by: Yu Kuai Link: https://lore.kernel.org/r/add654be-759f-4b2d-93ba-a3726dae380c@stanley.mountain Signed-off-by: Song Liu --- diff --git a/drivers/md/md-linear.c b/drivers/md/md-linear.c index 53bc3fda9edb..a382929ce7ba 100644 --- a/drivers/md/md-linear.c +++ b/drivers/md/md-linear.c @@ -204,8 +204,8 @@ static int linear_add(struct mddev *mddev, struct md_rdev *rdev) rdev->saved_raid_disk = -1; newconf = linear_conf(mddev, mddev->raid_disks + 1); - if (!newconf) - return -ENOMEM; + if (IS_ERR(newconf)) + return PTR_ERR(newconf); /* newconf->raid_disks already keeps a copy of * the increased * value of mddev->raid_disks, WARN_ONCE() is just used to make