Skip to content

Commit 41320b1

Browse files
PeterZhu789martinkpetersen
authored andcommitted
scsi: snic: Fix possible memory leak if device_add() fails
If device_add() returns error, the name allocated by dev_set_name() needs be freed. As the comment of device_add() says, put_device() should be used to give up the reference in the error path. So fix this by calling put_device(), then the name can be freed in kobject_cleanp(). Fixes: c8806b6 ("snic: driver for Cisco SCSI HBA") Signed-off-by: Zhu Wang <[email protected]> Acked-by: Narsimhulu Musini <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 04b5b5c commit 41320b1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/scsi/snic/snic_disc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ snic_tgt_create(struct snic *snic, struct snic_tgt_id *tgtid)
303303
"Snic Tgt: device_add, with err = %d\n",
304304
ret);
305305

306+
put_device(&tgt->dev);
306307
put_device(&snic->shost->shost_gendev);
307308
spin_lock_irqsave(snic->shost->host_lock, flags);
308309
list_del(&tgt->list);

0 commit comments

Comments
 (0)