linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH next] mmc: rtsx_usb_sdmmc: Fix uninitialized variable issue
@ 2025-08-21 12:32 Dan Carpenter
  2025-08-22 10:15 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-08-21 12:32 UTC (permalink / raw)
  To: Ricky Wu
  Cc: Ulf Hansson, Avri Altman, Wolfram Sang, Binbin Zhou, linux-mmc,
	linux-kernel, kernel-janitors

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")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/mmc/host/rtsx_usb_sdmmc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c b/drivers/mmc/host/rtsx_usb_sdmmc.c
index e1ed39c657c3..70bd21084b97 100644
--- a/drivers/mmc/host/rtsx_usb_sdmmc.c
+++ b/drivers/mmc/host/rtsx_usb_sdmmc.c
@@ -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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH next] mmc: rtsx_usb_sdmmc: Fix uninitialized variable issue
  2025-08-21 12:32 [PATCH next] mmc: rtsx_usb_sdmmc: Fix uninitialized variable issue Dan Carpenter
@ 2025-08-22 10:15 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2025-08-22 10:15 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Ricky Wu, Avri Altman, Wolfram Sang, Binbin Zhou, linux-mmc,
	linux-kernel, kernel-janitors

On Thu, 21 Aug 2025 at 14:32, Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/rtsx_usb_sdmmc.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c b/drivers/mmc/host/rtsx_usb_sdmmc.c
> index e1ed39c657c3..70bd21084b97 100644
> --- a/drivers/mmc/host/rtsx_usb_sdmmc.c
> +++ b/drivers/mmc/host/rtsx_usb_sdmmc.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-22 10:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-21 12:32 [PATCH next] mmc: rtsx_usb_sdmmc: Fix uninitialized variable issue Dan Carpenter
2025-08-22 10:15 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).