]> Git Repo - linux.git/commitdiff
scsi: snic: Fix possible memory leak if device_add() fails
authorZhu Wang <[email protected]>
Tue, 1 Aug 2023 11:14:21 +0000 (19:14 +0800)
committerMartin K. Petersen <[email protected]>
Tue, 8 Aug 2023 01:34:08 +0000 (21:34 -0400)
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: c8806b6c9e82 ("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]>
drivers/scsi/snic/snic_disc.c

index 3e2e5783924d03caed2efa21587d485d54c9acc4..e429ad23c396dab72d68434d57936dc1b7b6fbb4 100644 (file)
@@ -303,6 +303,7 @@ snic_tgt_create(struct snic *snic, struct snic_tgt_id *tgtid)
                              "Snic Tgt: device_add, with err = %d\n",
                              ret);
 
+               put_device(&tgt->dev);
                put_device(&snic->shost->shost_gendev);
                spin_lock_irqsave(snic->shost->host_lock, flags);
                list_del(&tgt->list);
This page took 0.062002 seconds and 4 git commands to generate.