Skip to content

Commit 65b8c8c

Browse files
author
Hans Verkuil
committed
media: pci: mgb4: fix potential spectre vulnerability
Fix smatch warnings: drivers/media/pci/mgb4/mgb4_sysfs_out.c:118 video_source_store() warn: potential spectre issue 'mgbdev->vin' [r] (local cap) drivers/media/pci/mgb4/mgb4_sysfs_out.c:122 video_source_store() warn: possible spectre second half. 'loopin_new' Signed-off-by: Hans Verkuil <[email protected]> Reviewed-by: Martin Tůma <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent ada092e commit 65b8c8c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/media/pci/mgb4/mgb4_sysfs_out.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include <linux/device.h>
11+
#include <linux/nospec.h>
1112
#include "mgb4_core.h"
1213
#include "mgb4_i2c.h"
1314
#include "mgb4_vout.h"
@@ -114,8 +115,10 @@ static ssize_t video_source_store(struct device *dev,
114115

115116
if (((config & 0xc) >> 2) < MGB4_VIN_DEVICES)
116117
loopin_old = mgbdev->vin[(config & 0xc) >> 2];
117-
if (val < MGB4_VIN_DEVICES)
118+
if (val < MGB4_VIN_DEVICES) {
119+
val = array_index_nospec(val, MGB4_VIN_DEVICES);
118120
loopin_new = mgbdev->vin[val];
121+
}
119122
if (loopin_old && loopin_cnt(loopin_old) == 1)
120123
mgb4_mask_reg(&mgbdev->video, loopin_old->config->regs.config,
121124
0x2, 0x0);

0 commit comments

Comments
 (0)