Skip to content

Commit

Permalink
media: mgb4: protect driver against spectre
Browse files Browse the repository at this point in the history
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: [email protected]
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
Reviewed-by: Martin Tůma <[email protected]>
  • Loading branch information
mchehab committed Oct 18, 2024
1 parent 9883a4d commit 2aee207
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/media/pci/mgb4/mgb4_cmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ void mgb4_cmt_set_vin_freq_range(struct mgb4_vin_dev *vindev,
u32 config;
size_t i;

freq_range = array_index_nospec(freq_range, ARRAY_SIZE(cmt_vals_in));

addr = cmt_addrs_in[vindev->config->id];
reg_set = cmt_vals_in[freq_range];

Expand Down

0 comments on commit 2aee207

Please sign in to comment.