Re: [PATCH next] media: i2c: fix error handling in ub960_rxport_add_serializer()

From: Harshit Mogalapalli
Date: Tue Jul 18 2023 - 10:10:52 EST


Hi Andy,

On 18/07/23 7:28 pm, Andy Shevchenko wrote:
On Tue, Jul 18, 2023 at 01:58:46AM -0700, 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.

...

- 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;

It should be changed to return PTR_ERR(...);

I just sent a V2 with this suggestion included.

Thanks,
Harshit