From 9726132b51fd877e2fcf571bc9d7f3b7e873e63b Mon Sep 17 00:00:00 2001 From: Ritesh Harjani Date: Wed, 30 Dec 2015 15:53:49 +0530 Subject: [PATCH] mmc: cmdq_hci: Fix NULL pointer dereference crash Add a check on cmdq_host->ops to avoid NULL pointer dereference, if sdhci_dumpregs is called before initializing cmdq_host->ops structure. Change-Id: Idd1794e162c7a53cc63504e15e6e490481f104a3 Signed-off-by: Ritesh Harjani --- drivers/mmc/host/cmdq_hci.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/cmdq_hci.h b/drivers/mmc/host/cmdq_hci.h index 53096fb3a2aa..91cb25b78481 100644 --- a/drivers/mmc/host/cmdq_hci.h +++ b/drivers/mmc/host/cmdq_hci.h @@ -215,7 +215,7 @@ struct cmdq_host_ops { static inline void cmdq_writel(struct cmdq_host *host, u32 val, int reg) { - if (unlikely(host->ops->write_l)) + if (unlikely(host->ops && host->ops->write_l)) host->ops->write_l(host, val, reg); else writel_relaxed(val, host->mmio + reg); @@ -223,7 +223,7 @@ static inline void cmdq_writel(struct cmdq_host *host, u32 val, int reg) static inline u32 cmdq_readl(struct cmdq_host *host, int reg) { - if (unlikely(host->ops->read_l)) + if (unlikely(host->ops && host->ops->read_l)) return host->ops->read_l(host, reg); else return readl_relaxed(host->mmio + reg);