Skip to contentSkip to conversation

media: ov2740: allow OTP data access during streaming

bug report Dan Carpenter 2 participants 2 messages Dec 2, 2020 – Dec 3, 2020 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

Hello Bingbu Cao,

This is a semi-automatic email about new static checker warnings.

The patch 5e6fd339b68d: "media: ov2740: allow OTP data access during streaming" from Nov 13, 2020, leads to the following Smatch complaint:

drivers/media/i2c/ov2740.c:609 ov2740_load_otp_data()
warn: variable dereferenced before check 'nvm' (see line 603)

drivers/media/i2c/ov2740.c
601 static int ov2740_load_otp_data(struct nvm_data *nvm)
602 {

   603		struct i2c_client *client = nvm->client;
                                            ^^^^^^^^^^^

Dereference

604 struct ov2740 *ov2740 = to_ov2740(i2c_get_clientdata(client));
605 u32 isp_ctrl00 = 0;
606 u32 isp_ctrl01 = 0;
607 int ret;
608
609 if (!nvm)

                    ^^^^

Checked too late.

610 return -EINVAL;
611

regards,
dan carpenter

#1 lore raw

Hi, Dan

Thanks for your report.

There is a patch from Colin King which is addressing this issue.
media: ov2740: fix dereference before null check on pointer nvm

Thank you!

________________________
BRs,
Bingbu Cao

Quoted 39 lines

-----Original Message-----
From: Dan Carpenter <[email protected]>
Sent: Wednesday, December 2, 2020 10:48 PM
To: Cao, Bingbu <[email protected]>
Cc: [email protected]
Subject: [bug report] media: ov2740: allow OTP data access during streaming

Hello Bingbu Cao,

This is a semi-automatic email about new static checker warnings.

The patch 5e6fd339b68d: "media: ov2740: allow OTP data access during streaming" from Nov 13, 2020, leads to the following Smatch complaint:

drivers/media/i2c/ov2740.c:609 ov2740_load_otp_data()
warn: variable dereferenced before check 'nvm' (see line 603)

drivers/media/i2c/ov2740.c
601 static int ov2740_load_otp_data(struct nvm_data *nvm)

   602	{
   603		struct i2c_client *client = nvm->client;
                                            ^^^^^^^^^^^ Dereference

   604		struct ov2740 *ov2740 =
to_ov2740(i2c_get_clientdata(client));
   605		u32 isp_ctrl00 = 0;
   606		u32 isp_ctrl01 = 0;
   607		int ret;
   608
   609		if (!nvm)
                    ^^^^

Checked too late.

   610			return -EINVAL;
   611

regards,
dan carpenter