Skip to content

Commit 05fbde3

Browse files
Damien Le Moalmartinkpetersen
authored andcommitted
scsi: sd: Fix potential NULL pointer dereference
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/[email protected] Fixes: 89d9475 ("sd: Implement support for ZBC devices") Reported-by: Dongliang Mu <[email protected]> Suggested-by: Christoph Hellwig <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Damien Le Moal <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 4094981 commit 05fbde3

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

drivers/scsi/sd.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3544,7 +3544,6 @@ static int sd_probe(struct device *dev)
35443544
out_put:
35453545
put_disk(gd);
35463546
out_free:
3547-
sd_zbc_release_disk(sdkp);
35483547
kfree(sdkp);
35493548
out:
35503549
scsi_autopm_put_device(sdp);

0 commit comments

Comments
 (0)