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] [thread-next>] [day] [month] [year] [list]
Message-ID: <1607047828.4733.172.camel@mhfsdcap03>
Date:   Fri, 4 Dec 2020 10:10:28 +0800
From:   Dongchun Zhu <dongchun.zhu@...iatek.com>
To:     Arnd Bergmann <arnd@...nel.org>
CC:     Mauro Carvalho Chehab <mchehab@...nel.org>,
        Nathan Chancellor <natechancellor@...il.com>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Sakari Ailus <sakari.ailus@...ux.intel.com>,
        Arnd Bergmann <arnd@...db.de>, <linux-media@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>,
        <clang-built-linux@...glegroups.com>, <tfiga@...gle.com>,
        <sj.huang@...iatek.com>
Subject: Re: [PATCH] media: i2c: fix an uninitialized error code

Hi Arnd,

Thanks for the patch.

On Thu, 2020-12-03 at 23:29 +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@...db.de>
> 
> Clang points out that the error handling in ov02a10_s_stream() is
> broken, and just returns a random error code:
> 
> drivers/media/i2c/ov02a10.c:537:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
>         if (ov02a10->streaming == on)
>             ^~~~~~~~~~~~~~~~~~~~~~~~
> drivers/media/i2c/ov02a10.c:568:9: note: uninitialized use occurs here
>         return ret;
>                ^~~
> drivers/media/i2c/ov02a10.c:537:2: note: remove the 'if' if its condition is always false
>         if (ov02a10->streaming == on)
>         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/media/i2c/ov02a10.c:533:9: note: initialize the variable 'ret' to silence this warning
>         int ret;
> 
> I assume that -EBUSY is the intended error code, so use that.
> 
> Fixes: 91807efbe8ec ("media: i2c: add OV02A10 image sensor driver")
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> ---
>  drivers/media/i2c/ov02a10.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/ov02a10.c b/drivers/media/i2c/ov02a10.c
> index 391718136ade..7ee9c904d9b5 100644
> --- a/drivers/media/i2c/ov02a10.c
> +++ b/drivers/media/i2c/ov02a10.c
> @@ -534,8 +534,10 @@ static int ov02a10_s_stream(struct v4l2_subdev *sd, int on)
>  
>  	mutex_lock(&ov02a10->mutex);
>  
> -	if (ov02a10->streaming == on)
> +	if (ov02a10->streaming == on) {
> +		ret = -EBUSY;
>  		goto unlock_and_return;
> +	}
>  
>  	if (on) {
>  		ret = pm_runtime_get_sync(&client->dev);

Only if sensor fails to stream on, ret can return a negative error code.
Thus ret above needs to be initialized to '0'.
Also you could fix the clang error like this.

static int ov02a10_s_stream(struct v4l2_subdev *sd, int on)
{
	struct ov02a10 *ov02a10 = to_ov02a10(sd);
	...
	int ret = 0;

	...
	if (ov02a10->streaming == on)
		goto unlock_and_return;

	...
}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ