From: Phil Reid <preid@electromag.com.au>
To: Pan Bian <bianpan2016@163.com>, Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@savoirfairelinux.com>,
Florian Fainelli <f.fainelli@gmail.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] net: dsa: lan9303: correctly check return value of devm_gpiod_get_optional
Date: Mon, 13 Nov 2017 12:08:49 +0800 [thread overview]
Message-ID: <251e5e33-8bbb-d745-63c8-95d7b34d95f0@electromag.com.au> (raw)
In-Reply-To: <1510501089-9451-1-git-send-email-bianpan2016@163.com>
On 12/11/2017 23:38, Pan Bian wrote:
> Function devm_gpiod_get_optional() returns an ERR_PTR on failure. Its
> return value should not be validated by a NULL check. Instead, use IS_ERR.
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---
> drivers/net/dsa/lan9303-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
> index b471413..6d3fc8f 100644
> --- a/drivers/net/dsa/lan9303-core.c
> +++ b/drivers/net/dsa/lan9303-core.c
> @@ -828,7 +828,7 @@ static void lan9303_probe_reset_gpio(struct lan9303 *chip,
> chip->reset_gpio = devm_gpiod_get_optional(chip->dev, "reset",
> GPIOD_OUT_LOW);
>
> - if (!chip->reset_gpio) {
> + if (IS_ERR(chip->reset_gpio)) {
> dev_dbg(chip->dev, "No reset GPIO defined\n");
> return;
> }
>
Should not an error actually report the error and error out (ie fail probe).
But a null is the optional return and ok. (ie when -ENOENT return from sub gpiod_get call).
IS_ERR should be a separate condition check I think.
related lan9303_handle_reset() always returns 0.
lan9303_probe checks lan9303_handle_reset() return value.
Probably should be checking lan9303_probe_reset_gpio() instead.
--
Regards
Phil Reid
next prev parent reply other threads:[~2017-11-13 4:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-12 15:38 Pan Bian
2017-11-12 18:29 ` Andrew Lunn
2017-11-13 4:08 ` Phil Reid [this message]
2017-11-13 4:38 ` Andrew Lunn
2017-11-14 12:35 ` David Miller
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=251e5e33-8bbb-d745-63c8-95d7b34d95f0@electromag.com.au \
--to=preid@electromag.com.au \
--cc=andrew@lunn.ch \
--cc=bianpan2016@163.com \
--cc=f.fainelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=vivien.didelot@savoirfairelinux.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
all inboxes | Powered by JetHome®