scsi: libsas: Fix error path in sas_notify_lldd_dev_found()
Subsystems (3)
PATCH 1/1 scsi: libsas: Fix error path in sas_notify_lldd_dev_found()
In sas_notify_lldd_dev_found(), if we can't find a device, then it seems like the wrong thing to mark the device as found and to increment the reference count. None of the callers ever drop the reference in that situation.
--- drivers/scsi/libsas/sas_discover.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/libsas/sas_discover.c +2 -1
@@ -182,10 +182,11 @@ int sas_notify_lldd_dev_found(struct domain_device *dev)pr_warn ("driver on host %s cannot handle device %016llx, error:%d\n" ,dev_name (sas_ha->dev),SAS_ADDR (dev->sas_addr), res); +return res; }set_bit (SAS_DEV_FOUND , &dev->state);kref_get (&dev->kref); -return res; +return 0 ; }
Signature · 1 line
2.28.0
ÔÚ 2020/9/5 20:58, Dan Carpenter дµÀ:
Quoted 19 lines
In
sas_notify_lldd_dev_found(), if we can't find a device, then it seems like the wrong thing to mark the device as found and to increment the reference count. None of the callers ever drop the reference in that situation.Fixes 735f7d2fedf5 ("[SCSI] libsas: fix domain_device leak")Signed-off-by Dan Carpenter <[email protected]>--- drivers/scsi/libsas/sas_discover.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/scsi/libsas/sas_discover.c +0
-0@@ -182,10 +182,11 @@ int sas_notify_lldd_dev_found(struct domain_device *dev) pr_warn("driver on host %s cannot handle device %016llx, error:%d\n", dev_name(sas_ha->dev),
drivers/scsi/libsas/sas_discover.c int sas_notify_lldd_dev_found(struct domain_device *dev) · line 192
Quoted 10 lines
drivers/scsi/libsas/sas_discover.c +2
-1SAS_ADDR(dev->sas_addr), res); +return res; }set_bit (SAS_DEV_FOUND , &dev->state);kref_get (&dev->kref); -return res; +return 0 ; }
Hi Dan, thanks for finding this,
Quoted 1 line · Dan Carpenter
In
sas_notify_lldd_dev_found(), if we can't find a device,
nit: the callback is for the LLDD is to allocate resources, device context etc., for that domain_device, and not find the device. The device has been found at this point.
Quoted 16 lines
then it seems
like the wrong thing to mark the device as found and to increment the reference count. None of the callers ever drop the reference in that situation.Fixes 735f7d2fedf5 ("[SCSI] libsas: fix domain_device leak")Signed-off-by Dan Carpenter <[email protected]>--- drivers/scsi/libsas/sas_discover.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/scsi/libsas/sas_discover.c +0
-0
drivers/scsi/libsas/sas_discover.c int sas_notify_lldd_dev_found(struct domain_device *dev) · line 189
Quoted 9 lines
drivers/scsi/libsas/sas_discover.c +2
-1@@ -182,10 +182,11 @@ int sas_notify_lldd_dev_found(struct domain_device *dev)pr_warn ("driver on host %s cannot handle device %016llx, error:%d\n" ,dev_name (sas_ha->dev),SAS_ADDR (dev->sas_addr), res); +return res; }set_bit (SAS_DEV_FOUND , &dev->state);kref_get (&dev->kref); -return res; +return 0 ;
This looks ok.
drivers/scsi/libsas/sas_discover.c int sas_notify_lldd_dev_found(struct domain_device *dev) · line 190
Quoted 1 line
drivers/scsi/libsas/sas_discover.c +0
-0}
Thanks,
John
Quoted 3 lines
Martin K. Petersen
AppliedQuoted 4 lines · Dan Carpenter
In
sas_notify_lldd_dev_found(), if we can't find a device, then it seems like the wrong thing to mark the device as found and to increment the reference count. None of the callers ever drop the reference in that situation.
Applied to 5.9/scsi-fixes, thanks!
[1/1] scsi: libsas: Fix error path in sas_notify_lldd_dev_found()
https://git.kernel.org/mkp/scsi/c/fdcb7900d9ab
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering