linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: qup: Add missing unwind goto in qup_i2c_probe()
@ 2023-04-18 13:56 Shuai Jiang
  2023-05-05  1:18 ` d202180596
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Shuai Jiang @ 2023-04-18 13:56 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Wolfram Sang,
	Ivan T. Ivanov, Sricharan R, Naveen Kaje, Austin Christ
  Cc: hust-os-kernel-patches, Shuai Jiang, Andy Gross, linux-arm-msm,
	linux-i2c, linux-kernel

Smatch Warns:
	drivers/i2c/busses/i2c-qup.c:1784 qup_i2c_probe()
	warn: missing unwind goto?

The goto label "fail_runtime" and "fail" will disable qup->pclk, 
but here qup->pclk failed to obtain, in order to be consistent, 
change the direct return to goto label "fail_dma".

Fixes: 10c5a8425968 ("i2c: qup: New bus driver for the Qualcomm QUP I2C controller")
Fixes: 515da746983b ("i2c: qup: add ACPI support")
Signed-off-by: Shuai Jiang <d202180596@hust.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
---
The issue is found by static analysis and remains untested.
---
 drivers/i2c/busses/i2c-qup.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
index 2e153f2f71b6..78682388e02e 100644
--- a/drivers/i2c/busses/i2c-qup.c
+++ b/drivers/i2c/busses/i2c-qup.c
@@ -1752,16 +1752,21 @@ static int qup_i2c_probe(struct platform_device *pdev)
 	if (!clk_freq || clk_freq > I2C_MAX_FAST_MODE_PLUS_FREQ) {
 		dev_err(qup->dev, "clock frequency not supported %d\n",
 			clk_freq);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto fail_dma;
 	}
 
 	qup->base = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(qup->base))
-		return PTR_ERR(qup->base);
+	if (IS_ERR(qup->base)) {
+		ret = PTR_ERR(qup->base);
+		goto fail_dma;
+	}
 
 	qup->irq = platform_get_irq(pdev, 0);
-	if (qup->irq < 0)
-		return qup->irq;
+	if (qup->irq < 0) {
+		ret = qup->irq;
+		goto fail_dma;
+	}
 
 	if (has_acpi_companion(qup->dev)) {
 		ret = device_property_read_u32(qup->dev,
@@ -1775,13 +1780,15 @@ static int qup_i2c_probe(struct platform_device *pdev)
 		qup->clk = devm_clk_get(qup->dev, "core");
 		if (IS_ERR(qup->clk)) {
 			dev_err(qup->dev, "Could not get core clock\n");
-			return PTR_ERR(qup->clk);
+			ret = PTR_ERR(qup->clk);
+			goto fail_dma;
 		}
 
 		qup->pclk = devm_clk_get(qup->dev, "iface");
 		if (IS_ERR(qup->pclk)) {
 			dev_err(qup->dev, "Could not get iface clock\n");
-			return PTR_ERR(qup->pclk);
+			ret = PTR_ERR(qup->pclk);
+			goto fail_dma;
 		}
 		qup_i2c_enable_clocks(qup);
 		src_clk_freq = clk_get_rate(qup->clk);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] i2c: qup: Add missing unwind goto in qup_i2c_probe()
  2023-04-18 13:56 [PATCH] i2c: qup: Add missing unwind goto in qup_i2c_probe() Shuai Jiang
@ 2023-05-05  1:18 ` d202180596
  2023-05-05  7:42   ` Dan Carpenter
  2023-06-10 10:54 ` Andi Shyti
  2023-06-14  8:45 ` Wolfram Sang
  2 siblings, 1 reply; 6+ messages in thread
From: d202180596 @ 2023-05-05  1:18 UTC (permalink / raw)
  To: andy gross, bjorn andersson, konrad dybcio, wolfram sang,
	ivan t. ivanov, sricharan r, naveen kaje, austin christ
  Cc: hust-os-kernel-patches, andy gross, linux-arm-msm, linux-i2c,
	linux-kernel


> -----原始邮件-----
> 发件人: "Shuai Jiang" <d202180596@hust.edu.cn>
> 发送时间: 2023-04-18 21:56:12 (星期二)
> 收件人: "Andy Gross" <agross@kernel.org>, "Bjorn Andersson" <andersson@kernel.org>, "Konrad Dybcio" <konrad.dybcio@linaro.org>, "Wolfram Sang" <wsa@kernel.org>, "Ivan T. Ivanov" <iivanov@mm-sol.com>, "Sricharan R" <sricharan@codeaurora.org>, "Naveen Kaje" <nkaje@codeaurora.org>, "Austin Christ" <austinwc@codeaurora.org>
> 抄送: hust-os-kernel-patches@googlegroups.com, "Shuai Jiang" <d202180596@hust.edu.cn>, "Andy Gross" <agross@codeaurora.org>, linux-arm-msm@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
> 主题: [PATCH] i2c: qup: Add missing unwind goto in qup_i2c_probe()
> 
> Smatch Warns:
> 	drivers/i2c/busses/i2c-qup.c:1784 qup_i2c_probe()
> 	warn: missing unwind goto?
> 
> The goto label "fail_runtime" and "fail" will disable qup->pclk, 
> but here qup->pclk failed to obtain, in order to be consistent, 
> change the direct return to goto label "fail_dma".
> 
> Fixes: 10c5a8425968 ("i2c: qup: New bus driver for the Qualcomm QUP I2C controller")
> Fixes: 515da746983b ("i2c: qup: add ACPI support")
> Signed-off-by: Shuai Jiang <d202180596@hust.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
> ---
> The issue is found by static analysis and remains untested.
> ---
>  drivers/i2c/busses/i2c-qup.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
> index 2e153f2f71b6..78682388e02e 100644
> --- a/drivers/i2c/busses/i2c-qup.c
> +++ b/drivers/i2c/busses/i2c-qup.c
> @@ -1752,16 +1752,21 @@ static int qup_i2c_probe(struct platform_device *pdev)
>  	if (!clk_freq || clk_freq > I2C_MAX_FAST_MODE_PLUS_FREQ) {
>  		dev_err(qup->dev, "clock frequency not supported %d\n",
>  			clk_freq);
> -		return -EINVAL;
> +		ret = -EINVAL;
> +		goto fail_dma;
>  	}
>  
>  	qup->base = devm_platform_ioremap_resource(pdev, 0);
> -	if (IS_ERR(qup->base))
> -		return PTR_ERR(qup->base);
> +	if (IS_ERR(qup->base)) {
> +		ret = PTR_ERR(qup->base);
> +		goto fail_dma;
> +	}
>  
>  	qup->irq = platform_get_irq(pdev, 0);
> -	if (qup->irq < 0)
> -		return qup->irq;
> +	if (qup->irq < 0) {
> +		ret = qup->irq;
> +		goto fail_dma;
> +	}
>  
>  	if (has_acpi_companion(qup->dev)) {
>  		ret = device_property_read_u32(qup->dev,
> @@ -1775,13 +1780,15 @@ static int qup_i2c_probe(struct platform_device *pdev)
>  		qup->clk = devm_clk_get(qup->dev, "core");
>  		if (IS_ERR(qup->clk)) {
>  			dev_err(qup->dev, "Could not get core clock\n");
> -			return PTR_ERR(qup->clk);
> +			ret = PTR_ERR(qup->clk);
> +			goto fail_dma;
>  		}
>  
>  		qup->pclk = devm_clk_get(qup->dev, "iface");
>  		if (IS_ERR(qup->pclk)) {
>  			dev_err(qup->dev, "Could not get iface clock\n");
> -			return PTR_ERR(qup->pclk);
> +			ret = PTR_ERR(qup->pclk);
> +			goto fail_dma;
>  		}
>  		qup_i2c_enable_clocks(qup);
>  		src_clk_freq = clk_get_rate(qup->clk);
> -- 
> 2.25.1

ping? 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: qup: Add missing unwind goto in qup_i2c_probe()
  2023-05-05  1:18 ` d202180596
@ 2023-05-05  7:42   ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2023-05-05  7:42 UTC (permalink / raw)
  To: d202180596
  Cc: andy gross, bjorn andersson, konrad dybcio, wolfram sang,
	ivan t. ivanov, sricharan r, naveen kaje, austin christ,
	hust-os-kernel-patches, andy gross, linux-arm-msm, linux-i2c,
	linux-kernel

On Fri, May 05, 2023 at 09:18:16AM +0800, d202180596@hust.edu.cn wrote:
> 
> > -----原始邮件-----
> > 发件人: "Shuai Jiang" <d202180596@hust.edu.cn>
> > 发送时间: 2023-04-18 21:56:12 (星期二)
              ^^^^^^^^^^

You can't ping the list when the merge window is open.  You have to wait
for a couple weeks after.

The weeks before and during the merge window are busy and then afterward
maintainers have to deal with the backlog of postponed stuff...

Just be patient.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: qup: Add missing unwind goto in qup_i2c_probe()
  2023-04-18 13:56 [PATCH] i2c: qup: Add missing unwind goto in qup_i2c_probe() Shuai Jiang
  2023-05-05  1:18 ` d202180596
@ 2023-06-10 10:54 ` Andi Shyti
  2023-06-14  8:45 ` Wolfram Sang
  2 siblings, 0 replies; 6+ messages in thread
From: Andi Shyti @ 2023-06-10 10:54 UTC (permalink / raw)
  To: Shuai Jiang
  Cc: Andy Gross, Bjorn Andersson, Konrad Dybcio, Wolfram Sang,
	Ivan T. Ivanov, Sricharan R, Naveen Kaje, Austin Christ,
	hust-os-kernel-patches, Andy Gross, linux-arm-msm, linux-i2c,
	linux-kernel

On Tue, Apr 18, 2023 at 09:56:12PM +0800, Shuai Jiang wrote:
> Smatch Warns:
> 	drivers/i2c/busses/i2c-qup.c:1784 qup_i2c_probe()
> 	warn: missing unwind goto?
> 
> The goto label "fail_runtime" and "fail" will disable qup->pclk, 
> but here qup->pclk failed to obtain, in order to be consistent, 
> change the direct return to goto label "fail_dma".
> 
> Fixes: 10c5a8425968 ("i2c: qup: New bus driver for the Qualcomm QUP I2C controller")
> Fixes: 515da746983b ("i2c: qup: add ACPI support")

These are not the correct Fixes, the correct fix is:

Fixes: 9cedf3b2f099 ("i2c: qup: Add bam dma capabilities")

> Signed-off-by: Shuai Jiang <d202180596@hust.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>

and

Cc: <stable@vger.kernel.org> # v4.6+

Patch looks good:

Reviewed-by: Andi Shyti <andi.shyti@kernel.org> 

Andi

> ---
> The issue is found by static analysis and remains untested.
> ---
>  drivers/i2c/busses/i2c-qup.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
> index 2e153f2f71b6..78682388e02e 100644
> --- a/drivers/i2c/busses/i2c-qup.c
> +++ b/drivers/i2c/busses/i2c-qup.c
> @@ -1752,16 +1752,21 @@ static int qup_i2c_probe(struct platform_device *pdev)
>  	if (!clk_freq || clk_freq > I2C_MAX_FAST_MODE_PLUS_FREQ) {
>  		dev_err(qup->dev, "clock frequency not supported %d\n",
>  			clk_freq);
> -		return -EINVAL;
> +		ret = -EINVAL;
> +		goto fail_dma;
>  	}
>  
>  	qup->base = devm_platform_ioremap_resource(pdev, 0);
> -	if (IS_ERR(qup->base))
> -		return PTR_ERR(qup->base);
> +	if (IS_ERR(qup->base)) {
> +		ret = PTR_ERR(qup->base);
> +		goto fail_dma;
> +	}
>  
>  	qup->irq = platform_get_irq(pdev, 0);
> -	if (qup->irq < 0)
> -		return qup->irq;
> +	if (qup->irq < 0) {
> +		ret = qup->irq;
> +		goto fail_dma;
> +	}
>  
>  	if (has_acpi_companion(qup->dev)) {
>  		ret = device_property_read_u32(qup->dev,
> @@ -1775,13 +1780,15 @@ static int qup_i2c_probe(struct platform_device *pdev)
>  		qup->clk = devm_clk_get(qup->dev, "core");
>  		if (IS_ERR(qup->clk)) {
>  			dev_err(qup->dev, "Could not get core clock\n");
> -			return PTR_ERR(qup->clk);
> +			ret = PTR_ERR(qup->clk);
> +			goto fail_dma;
>  		}
>  
>  		qup->pclk = devm_clk_get(qup->dev, "iface");
>  		if (IS_ERR(qup->pclk)) {
>  			dev_err(qup->dev, "Could not get iface clock\n");
> -			return PTR_ERR(qup->pclk);
> +			ret = PTR_ERR(qup->pclk);
> +			goto fail_dma;
>  		}
>  		qup_i2c_enable_clocks(qup);
>  		src_clk_freq = clk_get_rate(qup->clk);
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: qup: Add missing unwind goto in qup_i2c_probe()
  2023-04-18 13:56 [PATCH] i2c: qup: Add missing unwind goto in qup_i2c_probe() Shuai Jiang
  2023-05-05  1:18 ` d202180596
  2023-06-10 10:54 ` Andi Shyti
@ 2023-06-14  8:45 ` Wolfram Sang
  2 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2023-06-14  8:45 UTC (permalink / raw)
  To: Shuai Jiang
  Cc: Andy Gross, Bjorn Andersson, Konrad Dybcio, Ivan T. Ivanov,
	Sricharan R, Naveen Kaje, Austin Christ, hust-os-kernel-patches,
	Andy Gross, linux-arm-msm, linux-i2c, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 685 bytes --]

On Tue, Apr 18, 2023 at 09:56:12PM +0800, Shuai Jiang wrote:
> Smatch Warns:
> 	drivers/i2c/busses/i2c-qup.c:1784 qup_i2c_probe()
> 	warn: missing unwind goto?
> 
> The goto label "fail_runtime" and "fail" will disable qup->pclk, 
> but here qup->pclk failed to obtain, in order to be consistent, 
> change the direct return to goto label "fail_dma".
> 
> Fixes: 10c5a8425968 ("i2c: qup: New bus driver for the Qualcomm QUP I2C controller")
> Fixes: 515da746983b ("i2c: qup: add ACPI support")
> Signed-off-by: Shuai Jiang <d202180596@hust.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>

Applied to for-current, thanks! Thanks Andi, for the proper Fixes tag!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] i2c: qup: Add missing unwind goto in qup_i2c_probe()
@ 2023-04-18 13:26 Shuai Jiang
  0 siblings, 0 replies; 6+ messages in thread
From: Shuai Jiang @ 2023-04-18 13:26 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Ivan T. Ivanov,
	Wolfram Sang, Austin Christ, Naveen Kaje, Sricharan R
  Cc: hust-os-kernel-patches, Shuai Jiang, Andy Gross, linux-arm-msm,
	linux-i2c, linux-kernel

Smatch Warns:
	drivers/i2c/busses/i2c-qup.c:1784 qup_i2c_probe()
	warn: missing unwind goto?

The goto label "fail_runtime" and "fail" will disable qup->pclk, 
but here qup->pclk failed to obtain, in order to be consistent, 
change the direct return to goto label "fail_dma".

Fixes: 10c5a8425968 ("i2c: qup: New bus driver for the Qualcomm QUP I2C controller")
Fixes: 515da746983b ("i2c: qup: add ACPI support")
Signed-off-by: Shuai Jiang <d202180596@hust.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
---
The issue is found by static analysis and remains untested.
---
 drivers/i2c/busses/i2c-qup.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
index 2e153f2f71b6..78682388e02e 100644
--- a/drivers/i2c/busses/i2c-qup.c
+++ b/drivers/i2c/busses/i2c-qup.c
@@ -1752,16 +1752,21 @@ static int qup_i2c_probe(struct platform_device *pdev)
 	if (!clk_freq || clk_freq > I2C_MAX_FAST_MODE_PLUS_FREQ) {
 		dev_err(qup->dev, "clock frequency not supported %d\n",
 			clk_freq);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto fail_dma;
 	}
 
 	qup->base = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(qup->base))
-		return PTR_ERR(qup->base);
+	if (IS_ERR(qup->base)) {
+		ret = PTR_ERR(qup->base);
+		goto fail_dma;
+	}
 
 	qup->irq = platform_get_irq(pdev, 0);
-	if (qup->irq < 0)
-		return qup->irq;
+	if (qup->irq < 0) {
+		ret = qup->irq;
+		goto fail_dma;
+	}
 
 	if (has_acpi_companion(qup->dev)) {
 		ret = device_property_read_u32(qup->dev,
@@ -1775,13 +1780,15 @@ static int qup_i2c_probe(struct platform_device *pdev)
 		qup->clk = devm_clk_get(qup->dev, "core");
 		if (IS_ERR(qup->clk)) {
 			dev_err(qup->dev, "Could not get core clock\n");
-			return PTR_ERR(qup->clk);
+			ret = PTR_ERR(qup->clk);
+			goto fail_dma;
 		}
 
 		qup->pclk = devm_clk_get(qup->dev, "iface");
 		if (IS_ERR(qup->pclk)) {
 			dev_err(qup->dev, "Could not get iface clock\n");
-			return PTR_ERR(qup->pclk);
+			ret = PTR_ERR(qup->pclk);
+			goto fail_dma;
 		}
 		qup_i2c_enable_clocks(qup);
 		src_clk_freq = clk_get_rate(qup->clk);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-06-14  8:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 13:56 [PATCH] i2c: qup: Add missing unwind goto in qup_i2c_probe() Shuai Jiang
2023-05-05  1:18 ` d202180596
2023-05-05  7:42   ` Dan Carpenter
2023-06-10 10:54 ` Andi Shyti
2023-06-14  8:45 ` Wolfram Sang
  -- strict thread matches above, loose matches on Subject: below --
2023-04-18 13:26 Shuai Jiang

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).