Files
linux-stable-mirror/drivers/scsi
Damien Le Moal 0fcb0b131c scsi: sd: Fix potential NULL pointer dereference
[ Upstream commit 05fbde3a77 ]

If sd_probe() sees an early error before sdkp->device is initialized,
sd_zbc_release_disk() is called. This causes a NULL pointer dereference
when sd_is_zoned() is called inside that function. Avoid this by removing
the call to sd_zbc_release_disk() in sd_probe() error path.

This change is safe and does not result in zone information memory leakage
because the zone information for a zoned disk is allocated only when
sd_revalidate_disk() is called, at which point sdkp->disk_dev is fully set,
resulting in sd_disk_release() being called when needed to cleanup a disk
zone information using sd_zbc_release_disk().

Link: https://lore.kernel.org/r/20220601062544.905141-2-damien.lemoal@opensource.wdc.com
Fixes: 89d9475610 ("sd: Implement support for ZBC devices")
Reported-by: Dongliang Mu <mudongliangabcd@gmail.com>
Suggested-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-06-14 18:36:13 +02:00
..
2022-04-27 14:38:56 +02:00
2022-04-27 14:38:56 +02:00
2022-04-08 14:23:33 +02:00
2022-04-13 20:59:05 +02:00
2021-05-31 22:48:21 -04:00
2021-05-31 22:48:21 -04:00
2022-02-16 12:56:14 +01:00
2021-05-31 22:48:23 -04:00
2021-05-21 16:59:33 -04:00
2022-01-27 11:05:03 +01:00
2021-08-23 12:54:30 -06:00
2021-08-16 13:33:24 -04:00