linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mdio_bus: Fix PTR_ERR applied after initialization to constant
@ 2019-11-11  7:13 YueHaibing
  2019-11-12  6:01 ` David Miller
  2019-11-19 12:58 ` Harini Katakam
  0 siblings, 2 replies; 4+ messages in thread
From: YueHaibing @ 2019-11-11  7:13 UTC (permalink / raw)
  To: andrew, f.fainelli, hkallweit1, davem, mail
  Cc: netdev, linux-kernel, YueHaibing

Fix coccinelle warning:

./drivers/net/phy/mdio_bus.c:67:5-12: ERROR: PTR_ERR applied after initialization to constant on line 62
./drivers/net/phy/mdio_bus.c:68:5-12: ERROR: PTR_ERR applied after initialization to constant on line 62

Fix this by using IS_ERR before PTR_ERR

Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: 71dd6c0dff51 ("net: phy: add support for reset-controller")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/phy/mdio_bus.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 2e29ab8..3587656 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -64,11 +64,12 @@ static int mdiobus_register_reset(struct mdio_device *mdiodev)
 	if (mdiodev->dev.of_node)
 		reset = devm_reset_control_get_exclusive(&mdiodev->dev,
 							 "phy");
-	if (PTR_ERR(reset) == -ENOENT ||
-	    PTR_ERR(reset) == -ENOTSUPP)
-		reset = NULL;
-	else if (IS_ERR(reset))
-		return PTR_ERR(reset);
+	if (IS_ERR(reset)) {
+		if (PTR_ERR(reset) == -ENOENT || PTR_ERR(reset) == -ENOSYS)
+			reset = NULL;
+		else
+			return PTR_ERR(reset);
+	}
 
 	mdiodev->reset_ctrl = reset;
 
-- 
2.7.4



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

* Re: [PATCH] mdio_bus: Fix PTR_ERR applied after initialization to constant
  2019-11-11  7:13 [PATCH] mdio_bus: Fix PTR_ERR applied after initialization to constant YueHaibing
@ 2019-11-12  6:01 ` David Miller
  2019-11-19 12:58 ` Harini Katakam
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2019-11-12  6:01 UTC (permalink / raw)
  To: yuehaibing; +Cc: andrew, f.fainelli, hkallweit1, mail, netdev, linux-kernel

From: YueHaibing <yuehaibing@huawei.com>
Date: Mon, 11 Nov 2019 15:13:47 +0800

> Fix coccinelle warning:
> 
> ./drivers/net/phy/mdio_bus.c:67:5-12: ERROR: PTR_ERR applied after initialization to constant on line 62
> ./drivers/net/phy/mdio_bus.c:68:5-12: ERROR: PTR_ERR applied after initialization to constant on line 62
> 
> Fix this by using IS_ERR before PTR_ERR
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Fixes: 71dd6c0dff51 ("net: phy: add support for reset-controller")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Applied.


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

* Re: [PATCH] mdio_bus: Fix PTR_ERR applied after initialization to constant
  2019-11-11  7:13 [PATCH] mdio_bus: Fix PTR_ERR applied after initialization to constant YueHaibing
  2019-11-12  6:01 ` David Miller
@ 2019-11-19 12:58 ` Harini Katakam
  2019-11-19 13:26   ` Michal Simek
  1 sibling, 1 reply; 4+ messages in thread
From: Harini Katakam @ 2019-11-19 12:58 UTC (permalink / raw)
  To: YueHaibing
  Cc: Andrew Lunn, Florian Fainelli, Heiner Kallweit, David Miller,
	mail, netdev, linux-kernel, Michal Simek

On Mon, Nov 11, 2019 at 12:53 PM YueHaibing <yuehaibing@huawei.com> wrote:
>
> Fix coccinelle warning:
>
> ./drivers/net/phy/mdio_bus.c:67:5-12: ERROR: PTR_ERR applied after initialization to constant on line 62
> ./drivers/net/phy/mdio_bus.c:68:5-12: ERROR: PTR_ERR applied after initialization to constant on line 62
>
> Fix this by using IS_ERR before PTR_ERR
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Fixes: 71dd6c0dff51 ("net: phy: add support for reset-controller")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  drivers/net/phy/mdio_bus.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> index 2e29ab8..3587656 100644
> --- a/drivers/net/phy/mdio_bus.c
> +++ b/drivers/net/phy/mdio_bus.c
> @@ -64,11 +64,12 @@ static int mdiobus_register_reset(struct mdio_device *mdiodev)
>         if (mdiodev->dev.of_node)
>                 reset = devm_reset_control_get_exclusive(&mdiodev->dev,
>                                                          "phy");
> -       if (PTR_ERR(reset) == -ENOENT ||
> -           PTR_ERR(reset) == -ENOTSUPP)
> -               reset = NULL;
> -       else if (IS_ERR(reset))
> -               return PTR_ERR(reset);
> +       if (IS_ERR(reset)) {
> +               if (PTR_ERR(reset) == -ENOENT || PTR_ERR(reset) == -ENOSYS)
> +                       reset = NULL;
> +               else
> +                       return PTR_ERR(reset);
> +       }
>
>         mdiodev->reset_ctrl = reset;
>

Adding Michal Simek to add some test comments.

> --
> 2.7.4
>
>

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

* Re: [PATCH] mdio_bus: Fix PTR_ERR applied after initialization to constant
  2019-11-19 12:58 ` Harini Katakam
@ 2019-11-19 13:26   ` Michal Simek
  0 siblings, 0 replies; 4+ messages in thread
From: Michal Simek @ 2019-11-19 13:26 UTC (permalink / raw)
  To: Harini Katakam, YueHaibing, David Miller
  Cc: Andrew Lunn, Florian Fainelli, Heiner Kallweit, mail, netdev,
	linux-kernel, Michal Simek

Hi David,

On 19. 11. 19 13:58, Harini Katakam wrote:
> On Mon, Nov 11, 2019 at 12:53 PM YueHaibing <yuehaibing@huawei.com> wrote:
>>
>> Fix coccinelle warning:
>>
>> ./drivers/net/phy/mdio_bus.c:67:5-12: ERROR: PTR_ERR applied after initialization to constant on line 62
>> ./drivers/net/phy/mdio_bus.c:68:5-12: ERROR: PTR_ERR applied after initialization to constant on line 62
>>
>> Fix this by using IS_ERR before PTR_ERR
>>
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Fixes: 71dd6c0dff51 ("net: phy: add support for reset-controller")
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>> ---
>>  drivers/net/phy/mdio_bus.c | 11 ++++++-----
>>  1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
>> index 2e29ab8..3587656 100644
>> --- a/drivers/net/phy/mdio_bus.c
>> +++ b/drivers/net/phy/mdio_bus.c
>> @@ -64,11 +64,12 @@ static int mdiobus_register_reset(struct mdio_device *mdiodev)
>>         if (mdiodev->dev.of_node)
>>                 reset = devm_reset_control_get_exclusive(&mdiodev->dev,
>>                                                          "phy");
>> -       if (PTR_ERR(reset) == -ENOENT ||
>> -           PTR_ERR(reset) == -ENOTSUPP)
>> -               reset = NULL;
>> -       else if (IS_ERR(reset))
>> -               return PTR_ERR(reset);
>> +       if (IS_ERR(reset)) {
>> +               if (PTR_ERR(reset) == -ENOENT || PTR_ERR(reset) == -ENOSYS)
>> +                       reset = NULL;
>> +               else
>> +                       return PTR_ERR(reset);
>> +       }
>>
>>         mdiodev->reset_ctrl = reset;
>>
> 
> Adding Michal Simek to add some test comments.

This patch is causing access to bad area on Microblaze with axi ethernet
driver.

The issue is that origin patch was checking ENOTSUPP and new one is
using ENOSYS which completely changed kernel behavior.
And this is even not described in commit message.
I will send a patch to fix it and would be good to get it to v5.4.

Thanks,
Michal




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

end of thread, other threads:[~2019-11-19 13:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-11  7:13 [PATCH] mdio_bus: Fix PTR_ERR applied after initialization to constant YueHaibing
2019-11-12  6:01 ` David Miller
2019-11-19 12:58 ` Harini Katakam
2019-11-19 13:26   ` Michal Simek

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