From: Geert Uytterhoeven Date: Fri, 23 Feb 2018 12:44:19 +0000 (+0100) Subject: mmc: dw_mmc-k3: Fix out-of-bounds access through DT alias X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=cb65fc21f3877599e1c22710c5fdbefd0be010d4;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git mmc: dw_mmc-k3: Fix out-of-bounds access through DT alias commit 325501d9360eb42c7c51e6daa0d733844c1e790b upstream. The hs_timing_cfg[] array is indexed using a value derived from the "mshcN" alias in DT, which may lead to an out-of-bounds access. Fix this by adding a range check. Fixes: 361c7fe9b02eee7e ("mmc: dw_mmc-k3: add sd support for hi3660") Signed-off-by: Geert Uytterhoeven Reviewed-by: Shawn Lin Cc: Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/mmc/host/dw_mmc-k3.c b/drivers/mmc/host/dw_mmc-k3.c index 64cda84b2302..665afd849d27 100644 --- a/drivers/mmc/host/dw_mmc-k3.c +++ b/drivers/mmc/host/dw_mmc-k3.c @@ -135,6 +135,9 @@ static int dw_mci_hi6220_parse_dt(struct dw_mci *host) if (priv->ctrl_id < 0) priv->ctrl_id = 0; + if (priv->ctrl_id >= TIMING_MODE) + return -EINVAL; + host->priv = priv; return 0; }