mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
To: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: dan.carpenter@linaro.org, kernel-janitors@vger.kernel.org,
	error27@gmail.com
Subject: Re: [PATCH next] media: i2c: fix error handling in ub960_rxport_add_serializer()
Date: Tue, 18 Jul 2023 16:31:54 +0300	[thread overview]
Message-ID: <159ca9b9-0702-b347-3e4f-66272dfce55e@ideasonboard.com> (raw)
In-Reply-To: <20230718085846.3988564-1-harshit.m.mogalapalli@oracle.com>

Hi,

On 18/07/2023 11:58, 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@oracle.com>
> ---
> Found with static analysis, only compile tested. Although in
> drivers/media i2c_client_has_driver() checks are present, IS_ERR() would
> probably be sufficient here.
> ---
>   drivers/media/i2c/ds90ub960.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c
> index e101bcf2356a..88144e3ec183 100644
> --- a/drivers/media/i2c/ds90ub960.c
> +++ b/drivers/media/i2c/ds90ub960.c
> @@ -1662,7 +1662,7 @@ 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;

Good catch. I think this should be modified to return 
PTR_ERR(rxport->ser.client) instead of -EIO. Do you want to update the 
patch or shall I do the change?

  Tomi


  reply	other threads:[~2023-07-18 13:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-18  8:58 Harshit Mogalapalli
2023-07-18 13:31 ` Tomi Valkeinen [this message]
2023-07-18 13:38   ` Harshit Mogalapalli
2023-07-18 13:58 ` Andy Shevchenko
2023-07-18 14:10   ` Harshit Mogalapalli

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=159ca9b9-0702-b347-3e4f-66272dfce55e@ideasonboard.com \
    --to=tomi.valkeinen@ideasonboard.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=dan.carpenter@linaro.org \
    --cc=error27@gmail.com \
    --cc=harshit.m.mogalapalli@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®