Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: asic3: Fix potential null pointer dereference

We previously assumed 'mem_sdio' could be null but it is
dereferenced in ioremap(). Add a check to avoid a potential
null pointer dereference error.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Sachin Kamat and committed by
Lee Jones
44b61a9f 96758059

+7 -5
+7 -5
drivers/mfd/asic3.c
··· 899 899 ds1wm_resources[0].end >>= asic->bus_shift; 900 900 901 901 /* MMC */ 902 - asic->tmio_cnf = ioremap((ASIC3_SD_CONFIG_BASE >> asic->bus_shift) + 902 + if (mem_sdio) { 903 + asic->tmio_cnf = ioremap((ASIC3_SD_CONFIG_BASE >> asic->bus_shift) + 903 904 mem_sdio->start, 904 905 ASIC3_SD_CONFIG_SIZE >> asic->bus_shift); 905 - if (!asic->tmio_cnf) { 906 - ret = -ENOMEM; 907 - dev_dbg(asic->dev, "Couldn't ioremap SD_CONFIG\n"); 908 - goto out; 906 + if (!asic->tmio_cnf) { 907 + ret = -ENOMEM; 908 + dev_dbg(asic->dev, "Couldn't ioremap SD_CONFIG\n"); 909 + goto out; 910 + } 909 911 } 910 912 asic3_mmc_resources[0].start >>= asic->bus_shift; 911 913 asic3_mmc_resources[0].end >>= asic->bus_shift;