From bf3240bada0211b4a555d75f027181c8432b2d20 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Sat, 25 Mar 2017 13:17:00 +0000 Subject: [PATCH] mmc: bcm2835: Fix possible NULL ptr dereference in bcm2835_request This fixes a NULL pointer dereference in case of a MMC request with a set block count command and no data. Reported-by: Dan Carpenter Signed-off-by: Stefan Wahren Tested-by: Peter Robinson Reviewed-by: Jaehoon Chung Signed-off-by: Ulf Hansson --- drivers/mmc/host/bcm2835.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c index 7d1b0db7fbb7..1f343a477b3d 100644 --- a/drivers/mmc/host/bcm2835.c +++ b/drivers/mmc/host/bcm2835.c @@ -1200,7 +1200,8 @@ static void bcm2835_request(struct mmc_host *mmc, struct mmc_request *mrq) return; } - host->use_sbc = !!mrq->sbc && (host->mrq->data->flags & MMC_DATA_READ); + host->use_sbc = !!mrq->sbc && host->mrq->data && + (host->mrq->data->flags & MMC_DATA_READ); if (host->use_sbc) { if (bcm2835_send_command(host, mrq->sbc)) { if (!host->use_busy) -- 2.20.1