[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230214093801.1267044-1-harshit.m.mogalapalli@oracle.com>
Date: Tue, 14 Feb 2023 01:38:01 -0800
From: Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>
To: unlisted-recipients:; (no To-header on input)
Cc: harshit.m.mogalapalli@...il.com, error27@...il.com, hch@....de,
Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>,
Richard Weinberger <richard@....at>,
Miquel Raynal <miquel.raynal@...tlin.com>,
Vignesh Raghavendra <vigneshr@...com>,
linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH linux-next] ubi: block: Fix a possible use-after-free bug in ubiblock_create()
Smatch warns:
drivers/mtd/ubi/block.c:438 ubiblock_create()
warn: '&dev->list' not removed from list
'dev' is freed in 'out_free_dev:, but it is still on the list.
To fix this, delete the list item before freeing.
Fixes: 91cc8fbcc8c7 ("ubi: block: set BLK_MQ_F_BLOCKING")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>
---
Found by static analysis(smatch). Only Compile tested.
---
drivers/mtd/ubi/block.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
index f5d036203fe7..763704c8d05c 100644
--- a/drivers/mtd/ubi/block.c
+++ b/drivers/mtd/ubi/block.c
@@ -429,6 +429,7 @@ int ubiblock_create(struct ubi_volume_info *vi)
return 0;
out_remove_minor:
+ list_del(&dev->list);
idr_remove(&ubiblock_minor_idr, gd->first_minor);
out_cleanup_disk:
put_disk(dev->gd);
--
2.38.1
Powered by blists - more mailing lists