Skip to contentSkip to conversation

mmc: fix improper use of memset

PATCH In review Sam Edwards 3 participants 4 messages May 19, 2023 – Jun 1, 2023 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: fix improper use of memset

Buffers created through DEFINE_(CACHE_)ALIGN_BUFFER are actually pointers to the real underlying buffer. Using sizeof(...) is not appropriate in this case.

---

 drivers/mmc/mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/mmc.c +1 -1
index 1af6af82e6..72c1076c56 100644
@@ -2262,7 +2262,7 @@ static int mmc_startup_v4(struct mmc *mmc)
 		return 0;
 
 	if (!mmc->ext_csd)
-		memset(ext_csd_bkup, 0, sizeof(ext_csd_bkup));
+		memset(ext_csd_bkup, 0, MMC_MAX_BLOCK_LEN);
 
 	err = mmc_send_ext_csd(mmc, ext_csd);
 	if (err)
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Sam Edwards

Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button

Buffers created through DEFINE_(CACHE_)ALIGN_BUFFER are actually pointers to the real underlying buffer. Using sizeof(...) is not appropriate in this case.

---

  drivers/mmc/mmc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/mmc.c +0 -0
index 1af6af82e6..72c1076c56 100644

drivers/mmc/mmc.c static int mmc_startup_v4(struct mmc *mmc) · line 2265

Quoted 5 lines
drivers/mmc/mmc.c +1 -1
@@ -2262,7 +2262,7 @@ static int mmc_startup_v4(struct mmc *mmc)
                 return 0;
 
         if (!mmc->ext_csd)
-               memset(ext_csd_bkup, 0, sizeof(ext_csd_bkup));
+               memset(ext_csd_bkup, 0, MMC_MAX_BLOCK_LEN);

This looks correct to me. BTW: do you met any issues during test?

Quoted 6 lines
drivers/mmc/mmc.c +0 -1
         err = mmc_send_ext_csd(mmc, ext_csd);
         if (err)
--

2.39.2

#2 lore raw

Hi, Peng Fan! Thank you for your review. :)

Quoted 1 line · Peng Fan

This looks correct to me. BTW: do you met any issues during test?

I do not think I understand the question.

Are you asking, "Did you send this patch because the current MMC driver was having problems on a real device?" If so, the answer is no. I only sent this to resolve a compiler warning.

Or are you asking, "Did you have any problems while testing after making this change?" If so, the answer is still no. But I also do not know whether or not my use of this driver was hitting this specific memset() at all.

Kind regards,
Sam