public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH next] i2c: qcom-cci: Fix error checking in cci_probe()
@ 2023-08-23 19:42 Harshit Mogalapalli
  2023-08-24  9:10 ` Bryan O'Donoghue
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Harshit Mogalapalli @ 2023-08-23 19:42 UTC (permalink / raw)
  To: dmitry.baryshkov, Loic Poulain, Robert Foss, Andi Shyti,
	Liao Chang, Todor Tomov, Bjorn Andersson, Vinod Koul,
	Wolfram Sang, linux-i2c, linux-arm-msm, linux-kernel
  Cc: dan.carpenter, kernel-janitors, error27, harshit.m.mogalapalli,
	vegard.nossum

devm_clk_bulk_get_all() can return zero when no clocks are obtained.
Passing zero to dev_err_probe() is a success which is incorrect.

Fixes: 605efbf43813 ("i2c: qcom-cci: Use dev_err_probe in probe function")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
Only compile tested, found by static analysis with smatch.

https://lore.kernel.org/all/CAA8EJprTOjbOy7N5+8NiJaNNhK+_btdUUFcpHKPkMuCZj5umMA@mail.gmail.com/
^^ I reported initially here, Dmitry suggested we need to fix it in a
different patch.

the Fixes commit used above pointed this bug, but the real fixes tag is this:
Fixes: e517526195de ("i2c: Add Qualcomm CCI I2C driver")
---
 drivers/i2c/busses/i2c-qcom-cci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c
index cf13abec05f1..414882c57d7f 100644
--- a/drivers/i2c/busses/i2c-qcom-cci.c
+++ b/drivers/i2c/busses/i2c-qcom-cci.c
@@ -588,8 +588,10 @@ static int cci_probe(struct platform_device *pdev)
 	/* Clocks */
 
 	ret = devm_clk_bulk_get_all(dev, &cci->clocks);
-	if (ret < 1)
+	if (ret < 0)
 		return dev_err_probe(dev, ret, "failed to get clocks\n");
+	else if (!ret)
+		return dev_err_probe(dev, -EINVAL, "not enough clocks in DT\n");
 	cci->nclocks = ret;
 
 	/* Retrieve CCI clock rate */
-- 
2.39.3


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

* Re: [PATCH next] i2c: qcom-cci: Fix error checking in cci_probe()
  2023-08-23 19:42 [PATCH next] i2c: qcom-cci: Fix error checking in cci_probe() Harshit Mogalapalli
@ 2023-08-24  9:10 ` Bryan O'Donoghue
  2023-08-24 16:11 ` Andi Shyti
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Bryan O'Donoghue @ 2023-08-24  9:10 UTC (permalink / raw)
  To: Harshit Mogalapalli, dmitry.baryshkov, Loic Poulain, Robert Foss,
	Andi Shyti, Liao Chang, Todor Tomov, Bjorn Andersson, Vinod Koul,
	Wolfram Sang, linux-i2c, linux-arm-msm, linux-kernel
  Cc: dan.carpenter, kernel-janitors, error27, vegard.nossum

On 23/08/2023 20:42, Harshit Mogalapalli wrote:
> devm_clk_bulk_get_all() can return zero when no clocks are obtained.
> Passing zero to dev_err_probe() is a success which is incorrect.
> 
> Fixes: 605efbf43813 ("i2c: qcom-cci: Use dev_err_probe in probe function")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
> ---
> Only compile tested, found by static analysis with smatch.
> 
> https://lore.kernel.org/all/CAA8EJprTOjbOy7N5+8NiJaNNhK+_btdUUFcpHKPkMuCZj5umMA@mail.gmail.com/
> ^^ I reported initially here, Dmitry suggested we need to fix it in a
> different patch.
> 
> the Fixes commit used above pointed this bug, but the real fixes tag is this:
> Fixes: e517526195de ("i2c: Add Qualcomm CCI I2C driver")
> ---
>   drivers/i2c/busses/i2c-qcom-cci.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c
> index cf13abec05f1..414882c57d7f 100644
> --- a/drivers/i2c/busses/i2c-qcom-cci.c
> +++ b/drivers/i2c/busses/i2c-qcom-cci.c
> @@ -588,8 +588,10 @@ static int cci_probe(struct platform_device *pdev)
>   	/* Clocks */
>   
>   	ret = devm_clk_bulk_get_all(dev, &cci->clocks);
> -	if (ret < 1)
> +	if (ret < 0)
>   		return dev_err_probe(dev, ret, "failed to get clocks\n");
> +	else if (!ret)
> +		return dev_err_probe(dev, -EINVAL, "not enough clocks in DT\n");
>   	cci->nclocks = ret;
>   
>   	/* Retrieve CCI clock rate */
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

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

* Re: [PATCH next] i2c: qcom-cci: Fix error checking in cci_probe()
  2023-08-23 19:42 [PATCH next] i2c: qcom-cci: Fix error checking in cci_probe() Harshit Mogalapalli
  2023-08-24  9:10 ` Bryan O'Donoghue
@ 2023-08-24 16:11 ` Andi Shyti
  2023-08-25 20:07 ` Wolfram Sang
  2023-09-05  9:10 ` Dan Carpenter
  3 siblings, 0 replies; 7+ messages in thread
From: Andi Shyti @ 2023-08-24 16:11 UTC (permalink / raw)
  To: Harshit Mogalapalli
  Cc: dmitry.baryshkov, Loic Poulain, Robert Foss, Liao Chang,
	Todor Tomov, Bjorn Andersson, Vinod Koul, Wolfram Sang, linux-i2c,
	linux-arm-msm, linux-kernel, dan.carpenter, kernel-janitors,
	error27, vegard.nossum

Hi Harshit,

On Wed, Aug 23, 2023 at 12:42:02PM -0700, Harshit Mogalapalli wrote:
> devm_clk_bulk_get_all() can return zero when no clocks are obtained.
> Passing zero to dev_err_probe() is a success which is incorrect.
> 
> Fixes: 605efbf43813 ("i2c: qcom-cci: Use dev_err_probe in probe function")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>

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

Andi

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

* Re: [PATCH next] i2c: qcom-cci: Fix error checking in cci_probe()
  2023-08-23 19:42 [PATCH next] i2c: qcom-cci: Fix error checking in cci_probe() Harshit Mogalapalli
  2023-08-24  9:10 ` Bryan O'Donoghue
  2023-08-24 16:11 ` Andi Shyti
@ 2023-08-25 20:07 ` Wolfram Sang
  2023-09-05  9:10 ` Dan Carpenter
  3 siblings, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2023-08-25 20:07 UTC (permalink / raw)
  To: Harshit Mogalapalli
  Cc: dmitry.baryshkov, Loic Poulain, Robert Foss, Andi Shyti,
	Liao Chang, Todor Tomov, Bjorn Andersson, Vinod Koul, linux-i2c,
	linux-arm-msm, linux-kernel, dan.carpenter, kernel-janitors,
	error27, vegard.nossum

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

On Wed, Aug 23, 2023 at 12:42:02PM -0700, Harshit Mogalapalli wrote:
> devm_clk_bulk_get_all() can return zero when no clocks are obtained.
> Passing zero to dev_err_probe() is a success which is incorrect.
> 
> Fixes: 605efbf43813 ("i2c: qcom-cci: Use dev_err_probe in probe function")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>

Applied to for-next, thanks!


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

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

* Re: [PATCH next] i2c: qcom-cci: Fix error checking in cci_probe()
  2023-08-23 19:42 [PATCH next] i2c: qcom-cci: Fix error checking in cci_probe() Harshit Mogalapalli
                   ` (2 preceding siblings ...)
  2023-08-25 20:07 ` Wolfram Sang
@ 2023-09-05  9:10 ` Dan Carpenter
  2023-09-05  9:24   ` Harshit Mogalapalli
  2023-09-05 10:25   ` Andi Shyti
  3 siblings, 2 replies; 7+ messages in thread
From: Dan Carpenter @ 2023-09-05  9:10 UTC (permalink / raw)
  To: Harshit Mogalapalli
  Cc: dmitry.baryshkov, Loic Poulain, Robert Foss, Andi Shyti,
	Liao Chang, Todor Tomov, Bjorn Andersson, Vinod Koul,
	Wolfram Sang, linux-i2c, linux-arm-msm, linux-kernel,
	kernel-janitors, error27, vegard.nossum

On Wed, Aug 23, 2023 at 12:42:02PM -0700, Harshit Mogalapalli wrote:
> devm_clk_bulk_get_all() can return zero when no clocks are obtained.
> Passing zero to dev_err_probe() is a success which is incorrect.
> 
> Fixes: 605efbf43813 ("i2c: qcom-cci: Use dev_err_probe in probe function")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
> ---
> Only compile tested, found by static analysis with smatch.
> 
> https://lore.kernel.org/all/CAA8EJprTOjbOy7N5+8NiJaNNhK+_btdUUFcpHKPkMuCZj5umMA@mail.gmail.com/
> ^^ I reported initially here, Dmitry suggested we need to fix it in a
> different patch.
> 
> the Fixes commit used above pointed this bug, but the real fixes tag is this:
> Fixes: e517526195de ("i2c: Add Qualcomm CCI I2C driver")

This has already been applied but, for future reference, you should have
gone with the real fixes tag instead of where the static checker started
complaining.

regards,
dan carpenter


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

* Re: [PATCH next] i2c: qcom-cci: Fix error checking in cci_probe()
  2023-09-05  9:10 ` Dan Carpenter
@ 2023-09-05  9:24   ` Harshit Mogalapalli
  2023-09-05 10:25   ` Andi Shyti
  1 sibling, 0 replies; 7+ messages in thread
From: Harshit Mogalapalli @ 2023-09-05  9:24 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: dmitry.baryshkov, Loic Poulain, Robert Foss, Andi Shyti,
	Liao Chang, Todor Tomov, Bjorn Andersson, Vinod Koul,
	Wolfram Sang, linux-i2c, linux-arm-msm, linux-kernel,
	kernel-janitors, error27, vegard.nossum

Hi,

On 05/09/23 2:40 pm, Dan Carpenter wrote:
> On Wed, Aug 23, 2023 at 12:42:02PM -0700, Harshit Mogalapalli wrote:
>> devm_clk_bulk_get_all() can return zero when no clocks are obtained.
>> Passing zero to dev_err_probe() is a success which is incorrect.
>>
>> Fixes: 605efbf43813 ("i2c: qcom-cci: Use dev_err_probe in probe function")
>> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
>> ---
>> Only compile tested, found by static analysis with smatch.
>>
>> https://lore.kernel.org/all/CAA8EJprTOjbOy7N5+8NiJaNNhK+_btdUUFcpHKPkMuCZj5umMA@mail.gmail.com/
>> ^^ I reported initially here, Dmitry suggested we need to fix it in a
>> different patch.
>>
>> the Fixes commit used above pointed this bug, but the real fixes tag is this:
>> Fixes: e517526195de ("i2c: Add Qualcomm CCI I2C driver")
> 
> This has already been applied but, for future reference, you should have
> gone with the real fixes tag instead of where the static checker started
> complaining.
> 

Thank you for sharing this.
Will use the real fixes from next time.

Regards,
Harshit

> regards,
> dan carpenter
> 

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

* Re: [PATCH next] i2c: qcom-cci: Fix error checking in cci_probe()
  2023-09-05  9:10 ` Dan Carpenter
  2023-09-05  9:24   ` Harshit Mogalapalli
@ 2023-09-05 10:25   ` Andi Shyti
  1 sibling, 0 replies; 7+ messages in thread
From: Andi Shyti @ 2023-09-05 10:25 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Harshit Mogalapalli, dmitry.baryshkov, Loic Poulain, Robert Foss,
	Liao Chang, Todor Tomov, Bjorn Andersson, Vinod Koul,
	Wolfram Sang, linux-i2c, linux-arm-msm, linux-kernel,
	kernel-janitors, error27, vegard.nossum

Hi Dan,

On Tue, Sep 05, 2023 at 12:10:31PM +0300, Dan Carpenter wrote:
> On Wed, Aug 23, 2023 at 12:42:02PM -0700, Harshit Mogalapalli wrote:
> > devm_clk_bulk_get_all() can return zero when no clocks are obtained.
> > Passing zero to dev_err_probe() is a success which is incorrect.
> > 
> > Fixes: 605efbf43813 ("i2c: qcom-cci: Use dev_err_probe in probe function")
> > Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
> > ---
> > Only compile tested, found by static analysis with smatch.
> > 
> > https://lore.kernel.org/all/CAA8EJprTOjbOy7N5+8NiJaNNhK+_btdUUFcpHKPkMuCZj5umMA@mail.gmail.com/
> > ^^ I reported initially here, Dmitry suggested we need to fix it in a
> > different patch.
> > 
> > the Fixes commit used above pointed this bug, but the real fixes tag is this:
> > Fixes: e517526195de ("i2c: Add Qualcomm CCI I2C driver")
> 
> This has already been applied but, for future reference, you should have
> gone with the real fixes tag instead of where the static checker started
> complaining.

yeah... sorry... I normally check all the "Fixes:" tags, but
sometimes, out of sheer laziness, I trust the commit.

Andi

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

end of thread, other threads:[~2023-09-05 16:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-23 19:42 [PATCH next] i2c: qcom-cci: Fix error checking in cci_probe() Harshit Mogalapalli
2023-08-24  9:10 ` Bryan O'Donoghue
2023-08-24 16:11 ` Andi Shyti
2023-08-25 20:07 ` Wolfram Sang
2023-09-05  9:10 ` Dan Carpenter
2023-09-05  9:24   ` Harshit Mogalapalli
2023-09-05 10:25   ` Andi Shyti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox