scsi: fix memory leak of sdpk on when gd fails to allocate
On an allocation failure of gd, the current exit path is via
out_free_devt which leaves sdpk still allocated and hence it gets
leaked. Fix this by correcting the order of resource free'ing with a
change in the error exit path labels.
Detected by CoverityScan, CID#1399519 ("Resource Leak")
Fixes: 0dba1314d4
("scsi, block: fix duplicate bdi name registration crashes")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Bart Van Assche <Bart.VanAssche@sandisk.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
8bfcd1bf86
commit
f170396c14
|
@ -3213,10 +3213,10 @@ static int sd_probe(struct device *dev)
|
||||||
sd_devt = NULL;
|
sd_devt = NULL;
|
||||||
out_put:
|
out_put:
|
||||||
put_disk(gd);
|
put_disk(gd);
|
||||||
out_free:
|
|
||||||
kfree(sdkp);
|
|
||||||
out_free_devt:
|
out_free_devt:
|
||||||
kfree(sd_devt);
|
kfree(sd_devt);
|
||||||
|
out_free:
|
||||||
|
kfree(sdkp);
|
||||||
out:
|
out:
|
||||||
scsi_autopm_put_device(sdp);
|
scsi_autopm_put_device(sdp);
|
||||||
return error;
|
return error;
|
||||||
|
|
Loading…
Reference in New Issue