]> git.baikalelectronics.ru Git - kernel.git/commit
scsi: fix memory leak of sdpk on when gd fails to allocate
authorColin Ian King <colin.king@canonical.com>
Fri, 3 Feb 2017 19:38:54 +0000 (19:38 +0000)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 23 Feb 2017 00:20:32 +0000 (19:20 -0500)
commit06dc9e8a0ab6ce7e55db16e53f3c7f76b3ed5b0e
treef1b031e4a7b985f22a026feb18ae63da616b4527
parent6c26bdd60c5c6abe410131106e0bfe9aef4933d2
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: e993902543ac569377 ("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>
drivers/scsi/sd.c