2023-03-26 07:10:09

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH 1/2] dmaengine: mv_xor_v2: Fix an error code.

If the probe is deferred, -EPROBE_DEFER should be returned, not
+EPROBE_DEFER.

Fixes: 3cd2c313f1d6 ("dmaengine: mv_xor_v2: Fix clock resource by adding a register clock")
Signed-off-by: Christophe JAILLET <[email protected]>
---
drivers/dma/mv_xor_v2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/mv_xor_v2.c b/drivers/dma/mv_xor_v2.c
index 89790beba305..0991b8265829 100644
--- a/drivers/dma/mv_xor_v2.c
+++ b/drivers/dma/mv_xor_v2.c
@@ -752,7 +752,7 @@ static int mv_xor_v2_probe(struct platform_device *pdev)

xor_dev->clk = devm_clk_get(&pdev->dev, NULL);
if (PTR_ERR(xor_dev->clk) == -EPROBE_DEFER) {
- ret = EPROBE_DEFER;
+ ret = -EPROBE_DEFER;
goto disable_reg_clk;
}
if (!IS_ERR(xor_dev->clk)) {
--
2.34.1


2023-03-29 10:34:22

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 1/2] dmaengine: mv_xor_v2: Fix an error code.

I had thought I had a Smatch check for this but apparently not... I
have attached a check plus the error messages. Some places use positive
error codes intentionally.

regards,
dan carpenter




Attachments:
(No filename) (205.00 B)
check_positive_error_code.c (4.19 kB)
err-list (33.38 kB)
Download all attachments

2023-03-29 10:37:08

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 1/2] dmaengine: mv_xor_v2: Fix an error code.

On Sun, Mar 26, 2023 at 09:06:37AM +0200, Christophe JAILLET wrote:
> If the probe is deferred, -EPROBE_DEFER should be returned, not
> +EPROBE_DEFER.
>
> Fixes: 3cd2c313f1d6 ("dmaengine: mv_xor_v2: Fix clock resource by adding a register clock")
> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
> drivers/dma/mv_xor_v2.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma/mv_xor_v2.c b/drivers/dma/mv_xor_v2.c
> index 89790beba305..0991b8265829 100644
> --- a/drivers/dma/mv_xor_v2.c
> +++ b/drivers/dma/mv_xor_v2.c
> @@ -752,7 +752,7 @@ static int mv_xor_v2_probe(struct platform_device *pdev)
>
> xor_dev->clk = devm_clk_get(&pdev->dev, NULL);
> if (PTR_ERR(xor_dev->clk) == -EPROBE_DEFER) {
> - ret = EPROBE_DEFER;
> + ret = -EPROBE_DEFER;
> goto disable_reg_clk;

Heh. Looking through the Smatch results, I don't think this actually
affects runtime because driver_probe_device() checks for both positive
and negatives. People shouldn't be returning positives, of course, but
it appears there is a work around for bugs built in already.

regards,
dan carpenter

2023-03-29 11:05:53

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 1/2] dmaengine: mv_xor_v2: Fix an error code.

A bunch of false positives could be silenced by changing the assign
and return hooks to check for unsigned types:

static void match_assign(struct expression *expr)
{
if (expr_unsigned(expr->left))
return;
warn_on_positive_error(expr->right);
}

static void match_return(struct expression *expr)
{
struct symbol *type;

type = cur_func_return_type();
if (type_unsigned(type))
return;

warn_on_positive_error(expr);
}

regards,
dan carpenter

2023-03-31 11:55:45

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH 1/2] dmaengine: mv_xor_v2: Fix an error code.

On 26-03-23, 09:06, Christophe JAILLET wrote:
> If the probe is deferred, -EPROBE_DEFER should be returned, not
> +EPROBE_DEFER.

Applied both, thanks

--
~Vinod

2023-03-31 20:30:32

by Christophe JAILLET

[permalink] [raw]
Subject: Re: [PATCH 1/2] dmaengine: mv_xor_v2: Fix an error code.

Le 29/03/2023 à 12:27, Dan Carpenter a écrit :
> On Sun, Mar 26, 2023 at 09:06:37AM +0200, Christophe JAILLET wrote:
>> If the probe is deferred, -EPROBE_DEFER should be returned, not
>> +EPROBE_DEFER.
>>
>> Fixes: 3cd2c313f1d6 ("dmaengine: mv_xor_v2: Fix clock resource by adding a register clock")
>> Signed-off-by: Christophe JAILLET <[email protected]>
>> ---
>> drivers/dma/mv_xor_v2.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/dma/mv_xor_v2.c b/drivers/dma/mv_xor_v2.c
>> index 89790beba305..0991b8265829 100644
>> --- a/drivers/dma/mv_xor_v2.c
>> +++ b/drivers/dma/mv_xor_v2.c
>> @@ -752,7 +752,7 @@ static int mv_xor_v2_probe(struct platform_device *pdev)
>>
>> xor_dev->clk = devm_clk_get(&pdev->dev, NULL);
>> if (PTR_ERR(xor_dev->clk) == -EPROBE_DEFER) {
>> - ret = EPROBE_DEFER;
>> + ret = -EPROBE_DEFER;
>> goto disable_reg_clk;
>
> Heh. Looking through the Smatch results, I don't think this actually
> affects runtime because driver_probe_device() checks for both positive
> and negatives. People shouldn't be returning positives, of course, but
> it appears there is a work around for bugs built in already.

Correct, but weird.

I've tried to look at the history of [1], but couldn't find any rational
for it.

Apparently it was already in the v1 of the serie. [2]

CJ

[1]:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=45ddcb42949f825f0caa25352e825cede94b6aba
[2]: https://lore.kernel.org/all/[email protected]/

>
> regards,
> dan carpenter
>
>