All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Wei Yongjun <weiyj.lk@gmail.com>
Cc: Wim Van Sebroeck <wim@iguana.be>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Wei Yongjun <weiyongjun1@huawei.com>,
	linux-watchdog@vger.kernel.org
Subject: Re: [PATCH -next] watchdog: wdat_wdt: fix return value check in wdat_wdt_probe()
Date: Wed, 28 Sep 2016 08:52:16 -0700	[thread overview]
Message-ID: <20160928155216.GC29624@roeck-us.net> (raw)
In-Reply-To: <1475074286-13834-1-git-send-email-weiyj.lk@gmail.com>

On Wed, Sep 28, 2016 at 02:51:26PM +0000, Wei Yongjun wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> In case of error, the function devm_ioremap_resource() returns ERR_PTR()
> and never returns NULL. The NULL test in the return value check should
> be replaced with IS_ERR().
> 
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/watchdog/wdat_wdt.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/watchdog/wdat_wdt.c b/drivers/watchdog/wdat_wdt.c
> index 6b64645..4594723 100644
> --- a/drivers/watchdog/wdat_wdt.c
> +++ b/drivers/watchdog/wdat_wdt.c
> @@ -351,16 +351,17 @@ static int wdat_wdt_probe(struct platform_device *pdev)
>  		res = &pdev->resource[i];
>  		if (resource_type(res) == IORESOURCE_MEM) {
>  			reg = devm_ioremap_resource(&pdev->dev, res);
> +			if (IS_ERR(reg))
> +				return PTR_ERR(reg);
>  		} else if (resource_type(res) == IORESOURCE_IO) {
>  			reg = devm_ioport_map(&pdev->dev, res->start, 1);
> +			if (!reg)
> +				return -ENOMEM;
>  		} else {
>  			dev_err(&pdev->dev, "Unsupported resource\n");
>  			return -EINVAL;
>  		}
>  
> -		if (!reg)
> -			return -ENOMEM;
> -
>  		regs[i] = reg;
>  	}
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-09-28 15:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-28 14:51 [PATCH -next] watchdog: wdat_wdt: fix return value check in wdat_wdt_probe() Wei Yongjun
2016-09-28 14:59 ` Mika Westerberg
2016-09-28 21:50   ` Rafael J. Wysocki
2016-09-28 15:52 ` Guenter Roeck [this message]
2016-09-28 16:27 ` Rafael J. Wysocki

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=20160928155216.GC29624@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=weiyj.lk@gmail.com \
    --cc=weiyongjun1@huawei.com \
    --cc=wim@iguana.be \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.