linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Harini Katakam <harinik@xilinx.com>
To: YueHaibing <yuehaibing@huawei.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	David Miller <davem@davemloft.net>,
	mail@david-bauer.net, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Michal Simek <michal.simek@xilinx.com>
Subject: Re: [PATCH] mdio_bus: Fix PTR_ERR applied after initialization to constant
Date: Tue, 19 Nov 2019 18:28:12 +0530	[thread overview]
Message-ID: <CAFcVECJQH15y78YPurq_m2bDigQ6EzSCZHZMROHRFe-rJKw88g@mail.gmail.com> (raw)
In-Reply-To: <20191111071347.21712-1-yuehaibing@huawei.com>

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

  parent reply	other threads:[~2019-11-19 12:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2019-11-19 13:26   ` Michal Simek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFcVECJQH15y78YPurq_m2bDigQ6EzSCZHZMROHRFe-rJKw88g@mail.gmail.com \
    --to=harinik@xilinx.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mail@david-bauer.net \
    --cc=michal.simek@xilinx.com \
    --cc=netdev@vger.kernel.org \
    --cc=yuehaibing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).