diff mbox

[Resend] mfd: asic3: Fix potential null pointer dereference

Message ID 1402394434-903-1-git-send-email-sachin.kamat@linaro.org
State Accepted
Commit 44b61a9f23dabf27303d32b4947f017f69ca90f6
Headers show

Commit Message

Sachin Kamat June 10, 2014, 10 a.m. UTC
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>
---
 drivers/mfd/asic3.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Lee Jones June 16, 2014, 5:23 p.m. UTC | #1
On Tue, 10 Jun 2014, Sachin Kamat wrote:

> 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>
> ---
>  drivers/mfd/asic3.c |   12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c
> index 9f6294f2a070..9fc4186d4132 100644
> --- a/drivers/mfd/asic3.c
> +++ b/drivers/mfd/asic3.c
> @@ -899,13 +899,15 @@ static int __init asic3_mfd_probe(struct platform_device *pdev,
>  	ds1wm_resources[0].end   >>= asic->bus_shift;
>  
>  	/* MMC */
> -	asic->tmio_cnf = ioremap((ASIC3_SD_CONFIG_BASE >> asic->bus_shift) +
> +	if (mem_sdio) {
> +		asic->tmio_cnf = ioremap((ASIC3_SD_CONFIG_BASE >> asic->bus_shift) +
>  				 mem_sdio->start,
>  				 ASIC3_SD_CONFIG_SIZE >> asic->bus_shift);
> -	if (!asic->tmio_cnf) {
> -		ret = -ENOMEM;
> -		dev_dbg(asic->dev, "Couldn't ioremap SD_CONFIG\n");
> -		goto out;
> +		if (!asic->tmio_cnf) {
> +			ret = -ENOMEM;
> +			dev_dbg(asic->dev, "Couldn't ioremap SD_CONFIG\n");
> +			goto out;
> +		}
>  	}
>  	asic3_mmc_resources[0].start >>= asic->bus_shift;
>  	asic3_mmc_resources[0].end   >>= asic->bus_shift;
diff mbox

Patch

diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c
index 9f6294f2a070..9fc4186d4132 100644
--- a/drivers/mfd/asic3.c
+++ b/drivers/mfd/asic3.c
@@ -899,13 +899,15 @@  static int __init asic3_mfd_probe(struct platform_device *pdev,
 	ds1wm_resources[0].end   >>= asic->bus_shift;
 
 	/* MMC */
-	asic->tmio_cnf = ioremap((ASIC3_SD_CONFIG_BASE >> asic->bus_shift) +
+	if (mem_sdio) {
+		asic->tmio_cnf = ioremap((ASIC3_SD_CONFIG_BASE >> asic->bus_shift) +
 				 mem_sdio->start,
 				 ASIC3_SD_CONFIG_SIZE >> asic->bus_shift);
-	if (!asic->tmio_cnf) {
-		ret = -ENOMEM;
-		dev_dbg(asic->dev, "Couldn't ioremap SD_CONFIG\n");
-		goto out;
+		if (!asic->tmio_cnf) {
+			ret = -ENOMEM;
+			dev_dbg(asic->dev, "Couldn't ioremap SD_CONFIG\n");
+			goto out;
+		}
 	}
 	asic3_mmc_resources[0].start >>= asic->bus_shift;
 	asic3_mmc_resources[0].end   >>= asic->bus_shift;