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]
Message-ID: <0f37556d-629b-93bd-6c6d-60126d714a65@ideasonboard.com>
Date:   Tue, 18 Jul 2023 17:45:30 +0300
From:   Tomi Valkeinen <tomi.valkeinen@...asonboard.com>
To:     Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        Sakari Ailus <sakari.ailus@...ux.intel.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        linux-media@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     dan.carpenter@...aro.org, kernel-janitors@...r.kernel.org,
        error27@...il.com
Subject: Re: [PATCH v2 next] media: i2c: fix error handling in
 ub960_rxport_add_serializer()

On 18/07/2023 17:06, Harshit Mogalapalli wrote:
> Smatch warns:
>   drivers/media/i2c/ds90ub960.c:1671 ub960_rxport_add_serializer():
>   err: 'rxport->ser.client' dereferencing possible ERR_PTR()
> 
> i2c_new_client_device() returns error pointers on failure and in
> dev_dbg statement we are dereferencing error pointer which is a bug.
> 
> Fix this by using IS_ERR() which checks for error pointers.
> 
> Fixes: afe267f2d368 ("media: i2c: add DS90UB960 driver")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@...cle.com>
> ---
> This is based on static analysis and only compile tested.
> 
> V1->V2: Suggestion from Tomi Valkeinen: Propogate the error code with
> PTR_ERR() instead of -EIO.
> ---
>   drivers/media/i2c/ds90ub960.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c
> index e101bcf2356a..92aa004a3674 100644
> --- a/drivers/media/i2c/ds90ub960.c
> +++ b/drivers/media/i2c/ds90ub960.c
> @@ -1662,10 +1662,10 @@ static int ub960_rxport_add_serializer(struct ub960_data *priv, u8 nport)
>   	ser_info.addr = rxport->ser.alias;
>   	rxport->ser.client =
>   		i2c_new_client_device(priv->client->adapter, &ser_info);
> -	if (!rxport->ser.client) {
> +	if (IS_ERR(rxport->ser.client)) {
>   		dev_err(dev, "rx%u: cannot add %s i2c device", nport,
>   			ser_info.type);
> -		return -EIO;
> +		return PTR_ERR(rxport->ser.client);
>   	}
>   
>   	dev_dbg(dev, "rx%u: remote serializer at alias 0x%02x (%u-%04x)\n",

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@...asonboard.com>

  Tomi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ