Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: c8806b6c9e82 ("snic: driver for Cisco SCSI HBA")
Signed-off-by: Zhu Wang <wangzhu9@huawei.com>
Acked-by: Narsimhulu Musini <nmusini@cisco.com>
Link: https://lore.kernel.org/r/20230801111421.63651-1-wangzhu9@huawei.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Zhu Wang and committed by
Martin K. Petersen
41320b18 04b5b5cb

+1
+1
drivers/scsi/snic/snic_disc.c
··· 303 303 "Snic Tgt: device_add, with err = %d\n", 304 304 ret); 305 305 306 + put_device(&tgt->dev); 306 307 put_device(&snic->shost->shost_gendev); 307 308 spin_lock_irqsave(snic->shost->host_lock, flags); 308 309 list_del(&tgt->list);