Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1210495 > unrolled thread

Re: [PATCH] regulator: core: Use IS_ERR_OR_NULL()

Started byArnd Bergmann <arnd@arndb.de>
First post2015-08-20 15:30 +0200
Last post2015-08-20 18:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] regulator: core: Use IS_ERR_OR_NULL() Arnd Bergmann <arnd@arndb.de> - 2015-08-20 15:30 +0200
    Re: [PATCH] regulator: core: Use IS_ERR_OR_NULL() Viresh Kumar <viresh.kumar@linaro.org> - 2015-08-20 18:00 +0200

#1210495 — Re: [PATCH] regulator: core: Use IS_ERR_OR_NULL()

FromArnd Bergmann <arnd@arndb.de>
Date2015-08-20 15:30 +0200
SubjectRe: [PATCH] regulator: core: Use IS_ERR_OR_NULL()
Message-ID<pZy4U-68h-123@gated-at.bofh.it>
On Monday 17 August 2015 12:30:58 Viresh Kumar wrote:
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 78387a6cbae5..55b49acfd9b3 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -1595,7 +1595,7 @@ static void _regulator_put(struct regulator *regulator)
>  {
>         struct regulator_dev *rdev;
>  
> -       if (regulator == NULL || IS_ERR(regulator))
> +       if (IS_ERR_OR_NULL(regulator))
>                 return;

The use of IS_ERR_OR_NULL is almost always a bug (as is the open-coded
equivalent).
Please try to find out why this is done here and add a comment
if it's actually correct, or fix it if not.

My guess is that it is not ok to pass an error pointer as the argument
of _regulator_put(), so maybe there should be WARN_ON()?

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1210605

FromViresh Kumar <viresh.kumar@linaro.org>
Date2015-08-20 18:00 +0200
Message-ID<pZApY-YM-13@gated-at.bofh.it>
In reply to#1210495
On 20-08-15, 15:26, Arnd Bergmann wrote:
> The use of IS_ERR_OR_NULL is almost always a bug (as is the open-coded
> equivalent).
> Please try to find out why this is done here and add a comment
> if it's actually correct, or fix it if not.
> 
> My guess is that it is not ok to pass an error pointer as the argument
> of _regulator_put(), so maybe there should be WARN_ON()?

I agree, but updating that would require a revisit of all the API
users, in case they are passing a possible error value to it.

I am fine at attempting to fix that, but would need an Ack from Mark
first.

-- 
viresh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web