lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Sun, 31 Jul 2016 14:09:15 +0300
From:	Sakari Ailus <sakari.ailus@....fi>
To:	Amitoj Kaur Chawla <amitoj1606@...il.com>
Cc:	mchehab@....samsung.com, linux-media@...r.kernel.org,
	linux-kernel@...r.kernel.org, julia.lawall@...6.fr
Subject: Re: [PATCH] i2c: Modify error handling

Hi Amitoj,

On Sun, Jul 31, 2016 at 09:28:00AM +0530, Amitoj Kaur Chawla wrote:
> devm_gpiod_get returns an ERR_PTR on error so a null check is
> incorrect and an IS_ERR check is required.
> 
> The Coccinelle semantic patch used to make this change is as follows:
> @@
> expression e;
> statement S;
> @@
> 
>   e = devm_gpiod_get(...);
>  if(
> -   !e
> +   IS_ERR(e)
>    )
>   {
>    ...
> -  return ...;
> +  return PTR_ERR(e);
>   }
> 
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@...il.com>
> ---
>  drivers/media/i2c/adp1653.c | 4 ++--

In this exact case, the issue has been fixed by similar patch in media-tree
master branch. You likely used another branch for preparing this patch.

Nevertheless, thank you for the patch --- this kind of cleanups are always
much appreciated.

commit 806f8ffa8a0fa9a6f0481c5648c27aa51d10fdc6
Author: Vladimir Zapolskiy <vz@...ia.com>
Date:   Mon Mar 7 15:39:32 2016 -0300

    [media] media: i2c/adp1653: fix check of devm_gpiod_get() error code
    
    The devm_gpiod_get() function returns either a valid pointer to
    struct gpio_desc or ERR_PTR() error value, check for NULL is bogus.
    
    Signed-off-by: Vladimir Zapolskiy <vz@...ia.com>
    Signed-off-by: Sakari Ailus <sakari.ailus@...ux.intel.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@....samsung.com>

diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c
index fb7ed73..9e1731c 100644
--- a/drivers/media/i2c/adp1653.c
+++ b/drivers/media/i2c/adp1653.c
@@ -466,9 +466,9 @@ static int adp1653_of_init(struct i2c_client *client,
        of_node_put(child);
 
        pd->enable_gpio = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW);
-       if (!pd->enable_gpio) {
+       if (IS_ERR(pd->enable_gpio)) {
                dev_err(&client->dev, "Error getting GPIO\n");
-               return -EINVAL;
+               return PTR_ERR(pd->enable_gpio);
        }
 
        return 0;

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ailus@....fi	XMPP: sailus@...iisi.org.uk

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ