2023-03-02 01:42:29

by Asutosh Das

[permalink] [raw]
Subject: [PATCH v2 1/1] ufs: mcq: qcom: Fix passing zero to PTR_ERR

Fix an error case in ufs_qcom_mcq_config_resource(), where the
return value is set to 0 before passing it to PTR_ERR.

This led to Smatch warning:
drivers/ufs/host/ufs-qcom.c:1455 ufs_qcom_mcq_config_resource() warn:
passing zero to 'PTR_ERR'

Fixes: c263b4ef737e ("scsi: ufs: core: mcq: Configure resource regions")
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Asutosh Das <[email protected]>

--
v1 -> v2
- Split to 2 patches
- Addressed Mani's comments
--
---
drivers/ufs/host/ufs-qcom.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
index 34fc453f3eb1..43b1fc1ad33e 100644
--- a/drivers/ufs/host/ufs-qcom.c
+++ b/drivers/ufs/host/ufs-qcom.c
@@ -1451,8 +1451,8 @@ static int ufs_qcom_mcq_config_resource(struct ufs_hba *hba)
if (IS_ERR(res->base)) {
dev_err(hba->dev, "Failed to map res %s, err=%d\n",
res->name, (int)PTR_ERR(res->base));
- res->base = NULL;
ret = PTR_ERR(res->base);
+ res->base = NULL;
return ret;
}
}
--
2.7.4



2023-03-02 02:21:18

by Bjorn Andersson

[permalink] [raw]
Subject: Re: [PATCH v2 1/1] ufs: mcq: qcom: Fix passing zero to PTR_ERR

On Wed, Mar 01, 2023 at 05:41:06PM -0800, Asutosh Das wrote:
> Fix an error case in ufs_qcom_mcq_config_resource(), where the
> return value is set to 0 before passing it to PTR_ERR.
>
> This led to Smatch warning:
> drivers/ufs/host/ufs-qcom.c:1455 ufs_qcom_mcq_config_resource() warn:
> passing zero to 'PTR_ERR'
>
> Fixes: c263b4ef737e ("scsi: ufs: core: mcq: Configure resource regions")
> Reported-by: Dan Carpenter <[email protected]>
> Signed-off-by: Asutosh Das <[email protected]>

Reviewed-by: Bjorn Andersson <[email protected]>

>
> --
> v1 -> v2
> - Split to 2 patches
> - Addressed Mani's comments
> --
> ---
> drivers/ufs/host/ufs-qcom.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index 34fc453f3eb1..43b1fc1ad33e 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
> @@ -1451,8 +1451,8 @@ static int ufs_qcom_mcq_config_resource(struct ufs_hba *hba)
> if (IS_ERR(res->base)) {
> dev_err(hba->dev, "Failed to map res %s, err=%d\n",
> res->name, (int)PTR_ERR(res->base));
> - res->base = NULL;
> ret = PTR_ERR(res->base);
> + res->base = NULL;
> return ret;
> }
> }
> --
> 2.7.4
>

2023-03-02 07:31:10

by Manivannan Sadhasivam

[permalink] [raw]
Subject: Re: [PATCH v2 1/1] ufs: mcq: qcom: Fix passing zero to PTR_ERR

On Wed, Mar 01, 2023 at 05:41:06PM -0800, Asutosh Das wrote:
> Fix an error case in ufs_qcom_mcq_config_resource(), where the
> return value is set to 0 before passing it to PTR_ERR.
>
> This led to Smatch warning:
> drivers/ufs/host/ufs-qcom.c:1455 ufs_qcom_mcq_config_resource() warn:
> passing zero to 'PTR_ERR'
>
> Fixes: c263b4ef737e ("scsi: ufs: core: mcq: Configure resource regions")
> Reported-by: Dan Carpenter <[email protected]>
> Signed-off-by: Asutosh Das <[email protected]>

Reviewed-by: Manivannan Sadhasivam <[email protected]>

Thanks,
Mani

>
> --
> v1 -> v2
> - Split to 2 patches
> - Addressed Mani's comments
> --
> ---
> drivers/ufs/host/ufs-qcom.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index 34fc453f3eb1..43b1fc1ad33e 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
> @@ -1451,8 +1451,8 @@ static int ufs_qcom_mcq_config_resource(struct ufs_hba *hba)
> if (IS_ERR(res->base)) {
> dev_err(hba->dev, "Failed to map res %s, err=%d\n",
> res->name, (int)PTR_ERR(res->base));
> - res->base = NULL;
> ret = PTR_ERR(res->base);
> + res->base = NULL;
> return ret;
> }
> }
> --
> 2.7.4
>

--
மணிவண்ணன் சதாசிவம்

2023-03-07 02:58:07

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH v2 1/1] ufs: mcq: qcom: Fix passing zero to PTR_ERR

On Wed, 01 Mar 2023 17:41:06 -0800, Asutosh Das wrote:

> Fix an error case in ufs_qcom_mcq_config_resource(), where the
> return value is set to 0 before passing it to PTR_ERR.
>
> This led to Smatch warning:
> drivers/ufs/host/ufs-qcom.c:1455 ufs_qcom_mcq_config_resource() warn:
> passing zero to 'PTR_ERR'
>
> [...]

Applied to 6.3/scsi-fixes, thanks!

[1/1] ufs: mcq: qcom: Fix passing zero to PTR_ERR
https://git.kernel.org/mkp/scsi/c/c8be073bd2bc

--
Martin K. Petersen Oracle Linux Engineering