summaryrefslogtreecommitdiff
path: root/drivers/scsi/sd.c
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2017-02-03 22:38:54 +0300
committerMartin K. Petersen <martin.petersen@oracle.com>2017-02-23 03:20:32 +0300
commitf170396c14243d307e2f479af142fd7356b3bd2a (patch)
treef1b031e4a7b985f22a026feb18ae63da616b4527 /drivers/scsi/sd.c
parent8bfcd1bf867d5fae67ecc553b44d7a29ab66013c (diff)
downloadlinux-f170396c14243d307e2f479af142fd7356b3bd2a.tar.xz
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: 0dba1314d4f81115dc ("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>
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r--drivers/scsi/sd.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index b9b32f5811e0..8e4f4f72ea64 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3213,10 +3213,10 @@ static int sd_probe(struct device *dev)
sd_devt = NULL;
out_put:
put_disk(gd);
- out_free:
- kfree(sdkp);
out_free_devt:
kfree(sd_devt);
+ out_free:
+ kfree(sdkp);
out:
scsi_autopm_put_device(sdp);
return error;