Skip to content

Commit 2aee207

Browse files
committed
media: mgb4: protect driver against spectre
Frequency range is set from sysfs via frequency_range_store(), being vulnerable to spectre, as reported by smatch: drivers/media/pci/mgb4/mgb4_cmt.c:231 mgb4_cmt_set_vin_freq_range() warn: potential spectre issue 'cmt_vals_in' [r] drivers/media/pci/mgb4/mgb4_cmt.c:238 mgb4_cmt_set_vin_freq_range() warn: possible spectre second half. 'reg_set' Fix it. Fixes: 0ab1367 ("media: pci: mgb4: Added Digiteq Automotive MGB4 driver") Cc: stable@vger.kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Reviewed-by: Martin Tůma <martin.tuma@digiteqautomotive.com>
1 parent 9883a4d commit 2aee207

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/media/pci/mgb4/mgb4_cmt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ void mgb4_cmt_set_vin_freq_range(struct mgb4_vin_dev *vindev,
227227
u32 config;
228228
size_t i;
229229

230+
freq_range = array_index_nospec(freq_range, ARRAY_SIZE(cmt_vals_in));
231+
230232
addr = cmt_addrs_in[vindev->config->id];
231233
reg_set = cmt_vals_in[freq_range];
232234

0 commit comments

Comments
 (0)