Currently pointer nvm is being dereferenced before it is being null
checked. Fix this by moving the assignments of pointers client and
ov2740 so that are after the null check hence avoiding any potential
null pointer dereferences on pointer nvm.
Fixes:
5e6fd339b68d ("media: ov2740: allow OTP data access during streaming")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
static int ov2740_load_otp_data(struct nvm_data *nvm)
{
- struct i2c_client *client = nvm->client;
- struct ov2740 *ov2740 = to_ov2740(i2c_get_clientdata(client));
+ struct i2c_client *client;
+ struct ov2740 *ov2740;
u32 isp_ctrl00 = 0;
u32 isp_ctrl01 = 0;
int ret;
if (nvm->nvm_buffer)
return 0;
+ client = nvm->client;
+ ov2740 = to_ov2740(i2c_get_clientdata(client));
+
nvm->nvm_buffer = kzalloc(CUSTOMER_USE_OTP_SIZE, GFP_KERNEL);
if (!nvm->nvm_buffer)
return -ENOMEM;