Skip to content

Commit 4eeafff

Browse files
Chandra Mohan Sundargregkh
authored andcommitted
media: stm32-csi: Fix dereference before NULL check
commit 80eaf32672871bd2623ce6ba13ffc1f018756580 upstream. In 'stm32_csi_start', 'csidev->s_subdev' is dereferenced directly while assigning a value to the 'src_pad'. However the same value is being checked against NULL at a later point of time indicating that there are chances that the value can be NULL. Move the dereference after the NULL check. Fixes: e7bad98 ("media: v4l: Convert the users of v4l2_get_link_freq to call it on a pad") Cc: [email protected] Signed-off-by: Chandra Mohan Sundar <[email protected]> Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ec2f87a commit 4eeafff

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/media/platform/st/stm32/stm32-csi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,7 @@ static void stm32_csi_phy_reg_write(struct stm32_csi_dev *csidev,
443443
static int stm32_csi_start(struct stm32_csi_dev *csidev,
444444
struct v4l2_subdev_state *state)
445445
{
446-
struct media_pad *src_pad =
447-
&csidev->s_subdev->entity.pads[csidev->s_subdev_pad_nb];
446+
struct media_pad *src_pad;
448447
const struct stm32_csi_mbps_phy_reg *phy_regs = NULL;
449448
struct v4l2_mbus_framefmt *sink_fmt;
450449
const struct stm32_csi_fmts *fmt;
@@ -466,6 +465,7 @@ static int stm32_csi_start(struct stm32_csi_dev *csidev,
466465
if (!csidev->s_subdev)
467466
return -EIO;
468467

468+
src_pad = &csidev->s_subdev->entity.pads[csidev->s_subdev_pad_nb];
469469
link_freq = v4l2_get_link_freq(src_pad,
470470
fmt->bpp, 2 * csidev->num_lanes);
471471
if (link_freq < 0)

0 commit comments

Comments
 (0)