Skip to content

Commit 36ac969

Browse files
Ivan AbramovUlrich Hecht
authored andcommitted
media: adv7842: Avoid possible out-of-bounds array accesses in adv7842_cp_log_status()
commit 8163419e3e05d71dcfa8fb49c8fdf8d76908fe51 upstream. It's possible for cp_read() and hdmi_read() to return -EIO. Those values are further used as indexes for accessing arrays. Fix that by checking return values where it's needed. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: a89bcd4 ("[media] adv7842: add new video decoder driver") Cc: stable@vger.kernel.org Signed-off-by: Ivan Abramov <i.abramov@mt-integration.ru> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ulrich Hecht <uli@kernel.org>
1 parent eb56929 commit 36ac969

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

drivers/media/i2c/adv7842.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,6 +2661,7 @@ static int adv7842_cp_log_status(struct v4l2_subdev *sd)
26612661
/* CP block */
26622662
struct adv7842_state *state = to_state(sd);
26632663
struct v4l2_dv_timings timings;
2664+
int temp;
26642665
u8 reg_io_0x02 = io_read(sd, 0x02);
26652666
u8 reg_io_0x21 = io_read(sd, 0x21);
26662667
u8 reg_rep_0x77 = rep_read(sd, 0x77);
@@ -2783,8 +2784,9 @@ static int adv7842_cp_log_status(struct v4l2_subdev *sd)
27832784
(((reg_io_0x02 >> 2) & 0x01) ^ (reg_io_0x02 & 0x01)) ?
27842785
"(16-235)" : "(0-255)",
27852786
(reg_io_0x02 & 0x08) ? "enabled" : "disabled");
2787+
temp = cp_read(sd, 0xf4) >> 4;
27862788
v4l2_info(sd, "Color space conversion: %s\n",
2787-
csc_coeff_sel_rb[cp_read(sd, 0xf4) >> 4]);
2789+
temp < 0 ? "" : csc_coeff_sel_rb[temp]);
27882790

27892791
if (!is_digital_input(sd))
27902792
return 0;
@@ -2814,8 +2816,9 @@ static int adv7842_cp_log_status(struct v4l2_subdev *sd)
28142816
hdmi_read(sd, 0x5f));
28152817
v4l2_info(sd, "AV Mute: %s\n",
28162818
(hdmi_read(sd, 0x04) & 0x40) ? "on" : "off");
2819+
temp = hdmi_read(sd, 0x0b) >> 6;
28172820
v4l2_info(sd, "Deep color mode: %s\n",
2818-
deep_color_mode_txt[hdmi_read(sd, 0x0b) >> 6]);
2821+
temp < 0 ? "" : deep_color_mode_txt[temp]);
28192822

28202823
adv7842_log_infoframes(sd);
28212824

0 commit comments

Comments
 (0)