media: atomisp-mt9m114: Fix pointer dereferenced before checking
authorHaowen Bai <baihaowen@meizu.com>
Mon, 30 May 2022 07:58:01 +0000 (08:58 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 8 Jul 2022 16:38:35 +0000 (17:38 +0100)
The info->data is dereferencing before null checking, so move
it after checking.

Link: https://lore.kernel.org/linux-media/1653897481-25681-1-git-send-email-baihaowen@meizu.com
Signed-off-by: Haowen Bai <baihaowen@meizu.com>
Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c

index 00d6842c07d62739986da159b6aa1e3f4b315c00..3c81ab73cdae07124f272b614470af0c215a11bc 100644 (file)
@@ -616,13 +616,15 @@ static int mt9m114_get_intg_factor(struct i2c_client *client,
                                   struct camera_mipi_info *info,
                                   const struct mt9m114_res_struct *res)
 {
-       struct atomisp_sensor_mode_data *buf = &info->data;
+       struct atomisp_sensor_mode_data *buf;
        u32 reg_val;
        int ret;
 
        if (!info)
                return -EINVAL;
 
+       buf = &info->data;
+
        ret =  mt9m114_read_reg(client, MISENSOR_32BIT,
                                REG_PIXEL_CLK, &reg_val);
        if (ret)