mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mmc: dw_mmc: Fix potential null pointer risk
@ 2024-03-07  8:51 Aleksandr Mishin
  2024-03-07 10:57 ` Ulf Hansson
  0 siblings, 1 reply; 7+ messages in thread
From: Aleksandr Mishin @ 2024-03-07  8:51 UTC (permalink / raw)
  To: Jaehoon Chung
  Cc: Aleksandr Mishin, Ulf Hansson, Wen Zhiwei, linux-mmc,
	linux-kernel, lvc-project

In dw_mci_runtime_resume() 'host->slot' could be null, but check is not cover all corresponding code.
Fix this bug by changing check place.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 4a835afd808a (mmc: dw_mmc: Fix potential null pointer risk)
Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
---
 drivers/mmc/host/dw_mmc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 829af2c98a44..a4f124452abc 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -3570,8 +3570,10 @@ int dw_mci_runtime_resume(struct device *dev)
 		   DW_MCI_ERROR_FLAGS);
 	mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE);
 
+	if (!host->slot)
+		goto err;
 
-	if (host->slot && host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)
+	if (host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)
 		dw_mci_set_ios(host->slot->mmc, &host->slot->mmc->ios);
 
 	/* Force setup bus to guarantee available clock output */
-- 
2.30.2


^ permalink raw reply	[flat|nested] 7+ messages in thread
[parent not found: <CGME20211229023827epcas1p1c62596be323776d0abad266224c299e0@epcas1p1.samsung.com>]

end of thread, other threads:[~2024-03-12 11:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-07  8:51 [PATCH] mmc: dw_mmc: Fix potential null pointer risk Aleksandr Mishin
2024-03-07 10:57 ` Ulf Hansson
2024-03-07 19:02   ` Aleksandr Mishin
2024-03-12 11:29     ` Ulf Hansson
     [not found] <CGME20211229023827epcas1p1c62596be323776d0abad266224c299e0@epcas1p1.samsung.com>
2021-12-29  2:38 ` Wen Zhiwei
2021-12-30  8:35   ` Jaehoon Chung
2022-01-24 14:40   ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®