* [PATCH] scsi: libsas: Fix error path in sas_notify_lldd_dev_found()
@ 2020-09-05 12:58 Dan Carpenter
2020-09-07 1:37 ` Jason Yan
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2020-09-05 12:58 UTC (permalink / raw)
To: James E.J. Bottomley, Dan Williams
Cc: Martin K. Petersen, John Garry, Gustavo A. R. Silva, Jason Yan,
linux-scsi, linux-kernel, kernel-janitors
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 <dan.carpenter@oracle.com>
---
drivers/scsi/libsas/sas_discover.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
index cd7c7d269f6f..d0f9e90e3279 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -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;
}
--
2.28.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: libsas: Fix error path in sas_notify_lldd_dev_found()
2020-09-05 12:58 [PATCH] scsi: libsas: Fix error path in sas_notify_lldd_dev_found() Dan Carpenter
@ 2020-09-07 1:37 ` Jason Yan
2020-09-07 8:54 ` John Garry
2020-09-09 2:08 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Jason Yan @ 2020-09-07 1:37 UTC (permalink / raw)
To: Dan Carpenter, James E.J. Bottomley, Dan Williams
Cc: Martin K. Petersen, John Garry, Gustavo A. R. Silva, linux-scsi,
linux-kernel, kernel-janitors
在 2020/9/5 20:58, 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.
>
> Fixes: 735f7d2fedf5 ("[SCSI] libsas: fix domain_device leak")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/scsi/libsas/sas_discover.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
> index cd7c7d269f6f..d0f9e90e3279 100644
> --- a/drivers/scsi/libsas/sas_discover.c
> +++ b/drivers/scsi/libsas/sas_discover.c
> @@ -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;
> }
>
>
>
Hi Dan, thanks for finding this,
Reviewed-by: Jason Yan <yanaijie@huawei.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: libsas: Fix error path in sas_notify_lldd_dev_found()
2020-09-05 12:58 [PATCH] scsi: libsas: Fix error path in sas_notify_lldd_dev_found() Dan Carpenter
2020-09-07 1:37 ` Jason Yan
@ 2020-09-07 8:54 ` John Garry
2020-09-09 2:08 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: John Garry @ 2020-09-07 8:54 UTC (permalink / raw)
To: Dan Carpenter, James E.J. Bottomley, Dan Williams
Cc: Martin K. Petersen, Gustavo A. R. Silva, Jason Yan, linux-scsi,
linux-kernel, kernel-janitors
On 05/09/2020 13:58, Dan Carpenter wrote:
> 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.
> 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 <dan.carpenter@oracle.com>
> ---
> drivers/scsi/libsas/sas_discover.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
> index cd7c7d269f6f..d0f9e90e3279 100644
> --- a/drivers/scsi/libsas/sas_discover.c
> +++ b/drivers/scsi/libsas/sas_discover.c
> @@ -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.
> }
Thanks,
John
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: libsas: Fix error path in sas_notify_lldd_dev_found()
2020-09-05 12:58 [PATCH] scsi: libsas: Fix error path in sas_notify_lldd_dev_found() Dan Carpenter
2020-09-07 1:37 ` Jason Yan
2020-09-07 8:54 ` John Garry
@ 2020-09-09 2:08 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2020-09-09 2:08 UTC (permalink / raw)
To: Dan Carpenter, Dan Williams, James E.J. Bottomley
Cc: Martin K . Petersen, John Garry, linux-kernel, linux-scsi,
Gustavo A. R. Silva, kernel-janitors, Jason Yan
On Sat, 5 Sep 2020 15:58:36 +0300, Dan Carpenter wrote:
> 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
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-09 2:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-05 12:58 [PATCH] scsi: libsas: Fix error path in sas_notify_lldd_dev_found() Dan Carpenter
2020-09-07 1:37 ` Jason Yan
2020-09-07 8:54 ` John Garry
2020-09-09 2:08 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).