diff mbox

[2/3] mmc: usdhi6rol0: fix NULL pointer deref in debug print

Message ID 1439991696-28488-2-git-send-email-rabin.vincent@axis.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rabin Vincent Aug. 19, 2015, 1:41 p.m. UTC
host->sg is only set when we're transferring multiple blocks.  Check for
its availibility before dereferencing it in the timeout work debug
print.

Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
---
 drivers/mmc/host/usdhi6rol0.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Ulf Hansson Aug. 25, 2015, 12:07 p.m. UTC | #1
On 19 August 2015 at 15:41, Rabin Vincent <rabin.vincent@axis.com> wrote:
> host->sg is only set when we're transferring multiple blocks.  Check for
> its availibility before dereferencing it in the timeout work debug
> print.
>
> Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>

Thanks, applied for next!

Kind regards
Uffe


> ---
>  drivers/mmc/host/usdhi6rol0.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
> index 63d5d72..4188e84e 100644
> --- a/drivers/mmc/host/usdhi6rol0.c
> +++ b/drivers/mmc/host/usdhi6rol0.c
> @@ -1634,6 +1634,7 @@ static void usdhi6_timeout_work(struct work_struct *work)
>         struct usdhi6_host *host = container_of(d, struct usdhi6_host, timeout_work);
>         struct mmc_request *mrq = host->mrq;
>         struct mmc_data *data = mrq ? mrq->data : NULL;
> +       struct scatterlist *sg = host->sg ?: data->sg;
>
>         dev_warn(mmc_dev(host->mmc),
>                  "%s timeout wait %u CMD%d: IRQ 0x%08x:0x%08x, last IRQ 0x%08x\n",
> @@ -1669,7 +1670,7 @@ static void usdhi6_timeout_work(struct work_struct *work)
>                         "%c: page #%u @ +0x%zx %ux%u in SG%u. Current SG %u bytes @ %u\n",
>                         data->flags & MMC_DATA_READ ? 'R' : 'W', host->page_idx,
>                         host->offset, data->blocks, data->blksz, data->sg_len,
> -                       sg_dma_len(host->sg), host->sg->offset);
> +                       sg_dma_len(sg), sg->offset);
>                 usdhi6_sg_unmap(host, true);
>                 /*
>                  * If USDHI6_WAIT_FOR_DATA_END times out, we have already unmapped
> --
> 1.7.10.4
>
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
index 63d5d72..4188e84e 100644
--- a/drivers/mmc/host/usdhi6rol0.c
+++ b/drivers/mmc/host/usdhi6rol0.c
@@ -1634,6 +1634,7 @@  static void usdhi6_timeout_work(struct work_struct *work)
 	struct usdhi6_host *host = container_of(d, struct usdhi6_host, timeout_work);
 	struct mmc_request *mrq = host->mrq;
 	struct mmc_data *data = mrq ? mrq->data : NULL;
+	struct scatterlist *sg = host->sg ?: data->sg;
 
 	dev_warn(mmc_dev(host->mmc),
 		 "%s timeout wait %u CMD%d: IRQ 0x%08x:0x%08x, last IRQ 0x%08x\n",
@@ -1669,7 +1670,7 @@  static void usdhi6_timeout_work(struct work_struct *work)
 			"%c: page #%u @ +0x%zx %ux%u in SG%u. Current SG %u bytes @ %u\n",
 			data->flags & MMC_DATA_READ ? 'R' : 'W', host->page_idx,
 			host->offset, data->blocks, data->blksz, data->sg_len,
-			sg_dma_len(host->sg), host->sg->offset);
+			sg_dma_len(sg), sg->offset);
 		usdhi6_sg_unmap(host, true);
 		/*
 		 * If USDHI6_WAIT_FOR_DATA_END times out, we have already unmapped