Skip to contentSkip to conversation

mmc: rtsx_usb_sdmmc: Fix uninitialized variable issue

PATCH In review Dan Carpenter 2 participants 2 messages Aug 21, 2025 – Aug 22, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: rtsx_usb_sdmmc: Fix uninitialized variable issue

If rtsx_usb_get_card_status() fails then "val" isn't initialized. Move the use of "val" until after the error checking.

Fixes d2e6fb2c31a0 ("misc: rtsx: usb card reader: add OCP support")
---
 drivers/mmc/host/rtsx_usb_sdmmc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/host/rtsx_usb_sdmmc.c +3 -3
index e1ed39c657c3..70bd21084b97 100644
@@ -785,13 +785,13 @@ static int sdmmc_get_cd(struct mmc_host *mmc)
 
 	mutex_unlock(&ucr->dev_mutex);
 
-	/* get OCP status */
-	host->ocp_stat = (val >> 4) & 0x03;
-
 	/* Treat failed detection as non-exist */
 	if (err)
 		goto no_card;
 
+	/* get OCP status */
+	host->ocp_stat = (val >> 4) & 0x03;
+
 	if (val & SD_CD) {
 		host->card_exist = true;
 		return 1;
Signature · 1 line
2.47.2
#1 lore raw
Quoted 6 lines · Dan Carpenter

If rtsx_usb_get_card_status() fails then "val" isn't initialized. Move the use of "val" until after the error checking.

Fixes d2e6fb2c31a0 ("misc: rtsx: usb card reader: add OCP support")

Applied for next, thanks!

Kind regards
Uffe

Quoted 28 lines
---
 drivers/mmc/host/rtsx_usb_sdmmc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/host/rtsx_usb_sdmmc.c +3 -4
index e1ed39c657c3..70bd21084b97 100644
@@ -785,13 +785,13 @@ static int sdmmc_get_cd(struct mmc_host *mmc)
 
        mutex_unlock(&ucr->dev_mutex);
 
-       /* get OCP status */
-       host->ocp_stat = (val >> 4) & 0x03;
-
        /* Treat failed detection as non-exist */
        if (err)
                goto no_card;
 
+       /* get OCP status */
+       host->ocp_stat = (val >> 4) & 0x03;
+
        if (val & SD_CD) {
                host->card_exist = true;
                return 1;
--

2.47.2