diff options
author | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2020-09-01 12:05:57 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2020-09-03 11:09:32 +0200 |
commit | e4969cff95fb85bd242cd74905065a41e3d04ab9 (patch) | |
tree | 0dabf99a72a98b42bda7f0d99869414a9da29535 /drivers/media/radio/wl128x | |
parent | 13c129066845dc6b81f5e13ddaf854b053a9490f (diff) | |
download | linux-e4969cff95fb85bd242cd74905065a41e3d04ab9.tar.bz2 |
media: wl128x: get rid of a potential spectre issue
As reported by smatch:
drivers/media/radio/wl128x/fmdrv_common.c:736 fm_irq_handle_rdsdata_getcmd_resp() warn: potential spectre issue 'rds_fmt.data.groupdatabuff.buff>
Address it by using array_index_nospec().
While here, reorder the linux/ includes.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/radio/wl128x')
-rw-r--r-- | drivers/media/radio/wl128x/fmdrv_common.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c index 5c395da74e17..6142484d5cb4 100644 --- a/drivers/media/radio/wl128x/fmdrv_common.c +++ b/drivers/media/radio/wl128x/fmdrv_common.c @@ -19,9 +19,11 @@ * Author: Manjunatha Halli <manjunatha_halli@ti.com> */ -#include <linux/module.h> -#include <linux/firmware.h> #include <linux/delay.h> +#include <linux/firmware.h> +#include <linux/module.h> +#include <linux/nospec.h> + #include "fmdrv.h" #include "fmdrv_v4l2.h" #include "fmdrv_common.h" @@ -700,7 +702,7 @@ static void fm_irq_handle_rdsdata_getcmd_resp(struct fmdev *fmdev) struct fm_rds *rds = &fmdev->rx.rds; unsigned long group_idx, flags; u8 *rds_data, meta_data, tmpbuf[FM_RDS_BLK_SIZE]; - u8 type, blk_idx; + u8 type, blk_idx, idx; u16 cur_picode; u32 rds_len; @@ -733,9 +735,11 @@ static void fm_irq_handle_rdsdata_getcmd_resp(struct fmdev *fmdev) } /* Skip checkword (control) byte and copy only data byte */ - memcpy(&rds_fmt.data.groupdatabuff. - buff[blk_idx * (FM_RDS_BLK_SIZE - 1)], - rds_data, (FM_RDS_BLK_SIZE - 1)); + idx = array_index_nospec(blk_idx * (FM_RDS_BLK_SIZE - 1), + FM_RX_RDS_INFO_FIELD_MAX - (FM_RDS_BLK_SIZE - 1)); + + memcpy(&rds_fmt.data.groupdatabuff.buff[idx], rds_data, + FM_RDS_BLK_SIZE - 1); rds->last_blk_idx = blk_idx; |