From 48dcddd380fc940627e81643a80dfcf46306e9e1 Mon Sep 17 00:00:00 2001 From: Bhaumik Bhatt Date: Thu, 28 May 2020 16:56:21 -0700 Subject: [PATCH] mhi: core: Do a null pointer check before reading debug registers Not all registers can be set while dumping debug registers depending on the state of the device. For example, wake doorbell is not set until a READY state of the device is reached. Hence, we could access a NULL pointer while dumping debug registers. Avoid this by adding a check to skip the addresses which are not yet set. Change-Id: Iccf275705d87023613ad3ab0c2ab53bad7ab912a Signed-off-by: Bhaumik Bhatt --- drivers/bus/mhi/core/mhi_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/bus/mhi/core/mhi_main.c b/drivers/bus/mhi/core/mhi_main.c index 4ba83b09dc0c..217e02e8bb19 100644 --- a/drivers/bus/mhi/core/mhi_main.c +++ b/drivers/bus/mhi/core/mhi_main.c @@ -2673,6 +2673,8 @@ void mhi_debug_reg_dump(struct mhi_controller *mhi_cntrl) TO_MHI_STATE_STR(state)); for (i = 0; debug_reg[i].name; i++) { + if (!debug_reg[i].base) + continue; ret = mhi_read_reg(mhi_cntrl, debug_reg[i].base, debug_reg[i].offset, &val); MHI_LOG("reg:%s val:0x%x, ret:%d\n", debug_reg[i].name, val,