summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Battersby <tonyb@cybernetics.com>2018-07-12 23:30:45 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-08-06 17:18:22 +0300
commitbced7cbdcc36743e357480f067cea89d97c10e3d (patch)
tree038813765b05f3fabd3d1a8318e52227aac1fdd5
parent9d61d4bdf223006219b182c8e473ae7dc127b74b (diff)
downloadlinux-bced7cbdcc36743e357480f067cea89d97c10e3d.tar.xz
scsi: sg: fix minor memory leak in error path
commit c170e5a8d222537e98aa8d4fddb667ff7a2ee114 upstream. Fix a minor memory leak when there is an error opening a /dev/sg device. Fixes: cc833acbee9d ("sg: O_EXCL and other lock handling") Cc: <stable@vger.kernel.org> Reviewed-by: Ewan D. Milne <emilne@redhat.com> Signed-off-by: Tony Battersby <tonyb@cybernetics.com> Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/scsi/sg.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index ecc87a53294f..71cadee2f769 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -2186,6 +2186,7 @@ sg_add_sfp(Sg_device * sdp)
write_lock_irqsave(&sdp->sfd_lock, iflags);
if (atomic_read(&sdp->detaching)) {
write_unlock_irqrestore(&sdp->sfd_lock, iflags);
+ kfree(sfp);
return ERR_PTR(-ENODEV);
}
list_add_tail(&sfp->sfd_siblings, &sdp->sfds);