2019-03-14 06:45:18

by Kangjie Lu

[permalink] [raw]
Subject: [PATCH] scsi: ufs: fix a missing check of devm_reset_control_get

devm_reset_control_get could fail, so the fix checks its
return value and pass the error code upstream in case it fails.

Signed-off-by: Kangjie Lu <[email protected]>
---
drivers/scsi/ufs/ufs-hisi.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/scsi/ufs/ufs-hisi.c b/drivers/scsi/ufs/ufs-hisi.c
index 452e19f8fb47..ce9d7c40909f 100644
--- a/drivers/scsi/ufs/ufs-hisi.c
+++ b/drivers/scsi/ufs/ufs-hisi.c
@@ -544,6 +544,11 @@ static int ufs_hisi_init_common(struct ufs_hba *hba)
ufshcd_set_variant(hba, host);

host->rst = devm_reset_control_get(dev, "rst");
+ if (IS_ERR(host->rst)) {
+ dev_err(dev, "%s: failed to get reset control\n",
+ __func__);
+ return PTR_ERR(host->rst);
+ }

ufs_hisi_set_pm_lvl(hba);

--
2.17.1



2019-03-14 09:16:09

by Avri Altman

[permalink] [raw]
Subject: RE: [PATCH] scsi: ufs: fix a missing check of devm_reset_control_get

Hi,
>
> Signed-off-by: Kangjie Lu <[email protected]>
Acked-by: Avri Altman <[email protected]>

> ---
> drivers/scsi/ufs/ufs-hisi.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/scsi/ufs/ufs-hisi.c b/drivers/scsi/ufs/ufs-hisi.c
> index 452e19f8fb47..ce9d7c40909f 100644
> --- a/drivers/scsi/ufs/ufs-hisi.c
> +++ b/drivers/scsi/ufs/ufs-hisi.c
> @@ -544,6 +544,11 @@ static int ufs_hisi_init_common(struct ufs_hba *hba)
> ufshcd_set_variant(hba, host);
>
> host->rst = devm_reset_control_get(dev, "rst");
> + if (IS_ERR(host->rst)) {
> + dev_err(dev, "%s: failed to get reset control\n",
> + __func__);
Use full line please

> + return PTR_ERR(host->rst);
> + }
>
> ufs_hisi_set_pm_lvl(hba);
>
> --
> 2.17.1


2019-03-15 07:13:08

by Kangjie Lu

[permalink] [raw]
Subject: [PATCH v2] scsi: ufs: fix a missing check of devm_reset_control_get

devm_reset_control_get could fail, so the fix checks its
return value and passes the error code upstream in case it fails.

Signed-off-by: Kangjie Lu <[email protected]>

Acked-by: Avri Altman <[email protected]>

---
V2: Use full line please
---
drivers/scsi/ufs/ufs-hisi.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/scsi/ufs/ufs-hisi.c b/drivers/scsi/ufs/ufs-hisi.c
index 452e19f8fb47..c2cee73a8560 100644
--- a/drivers/scsi/ufs/ufs-hisi.c
+++ b/drivers/scsi/ufs/ufs-hisi.c
@@ -544,6 +544,10 @@ static int ufs_hisi_init_common(struct ufs_hba *hba)
ufshcd_set_variant(hba, host);

host->rst = devm_reset_control_get(dev, "rst");
+ if (IS_ERR(host->rst)) {
+ dev_err(dev, "%s: failed to get reset control\n", __func__);
+ return PTR_ERR(host->rst);
+ }

ufs_hisi_set_pm_lvl(hba);

--
2.17.1


2019-03-19 18:38:47

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH v2] scsi: ufs: fix a missing check of devm_reset_control_get


Kangjie,

> devm_reset_control_get could fail, so the fix checks its return value
> and passes the error code upstream in case it fails.

Applied to 5.2/scsi-queue, thanks.

--
Martin K. Petersen Oracle Linux Engineering