From 88d0facf186c6c652c2203536fecd77089b43a4e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Pouiller?= Date: Fri, 11 Oct 2019 16:47:51 +0000 Subject: [PATCH] staging: wfx: fix potential vulnerability to spectre MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit array_index_nospec() should be applied after a bound check. Fixes: 9bca45f3d692 ("staging: wfx: allow to send 802.11 frames") Reported-by: kbuild test robot Reported-by: Dan Carpenter Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191011164746.2518-1-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/wfx.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 489836837b0a..d678b5a08873 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "bh.h" @@ -138,6 +139,7 @@ static inline struct wfx_vif *wdev_to_wvif(struct wfx_dev *wdev, int vif_id) dev_dbg(wdev->dev, "requesting non-existent vif: %d\n", vif_id); return NULL; } + vif_id = array_index_nospec(vif_id, ARRAY_SIZE(wdev->vif)); if (!wdev->vif[vif_id]) { dev_dbg(wdev->dev, "requesting non-allocated vif: %d\n", vif_id); return NULL; -- 2.11.0