diff options
author | Tony Battersby <tonyb@cybernetics.com> | 2018-07-12 16:30:45 -0400 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2018-07-12 23:08:10 -0400 |
commit | c170e5a8d222537e98aa8d4fddb667ff7a2ee114 (patch) | |
tree | 332831db1eb5b6ed4e0b2fa2383404b946bbfca2 | |
parent | a17037e7d59075053b522048742a08ac9500bde8 (diff) |
scsi: sg: fix minor memory leak in error path
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>
-rw-r--r-- | drivers/scsi/sg.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index cd2fdac000c9..2962a38c5068 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -2185,6 +2185,7 @@ sg_add_sfp(Sg_device * sdp) | |||
2185 | write_lock_irqsave(&sdp->sfd_lock, iflags); | 2185 | write_lock_irqsave(&sdp->sfd_lock, iflags); |
2186 | if (atomic_read(&sdp->detaching)) { | 2186 | if (atomic_read(&sdp->detaching)) { |
2187 | write_unlock_irqrestore(&sdp->sfd_lock, iflags); | 2187 | write_unlock_irqrestore(&sdp->sfd_lock, iflags); |
2188 | kfree(sfp); | ||
2188 | return ERR_PTR(-ENODEV); | 2189 | return ERR_PTR(-ENODEV); |
2189 | } | 2190 | } |
2190 | list_add_tail(&sfp->sfd_siblings, &sdp->sfds); | 2191 | list_add_tail(&sfp->sfd_siblings, &sdp->sfds); |