[PATCH] mmc: Take cleanup path to free memory on error exit
Andrew Goodbody
andrew.goodbody at linaro.org
Thu Jul 3 16:03:30 CEST 2025
Instead of returning -EINVAL directly which will not call the cleanup
path to free memory, fix the code to set the error and then goto the
cleanup code.
This issue found by Smatch.
Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
---
drivers/mmc/mmc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index cdcf2e0c8fe..eddcf86bb32 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2364,8 +2364,10 @@ static int mmc_startup_v4(struct mmc *mmc)
return -ENOMEM;
memcpy(mmc->ext_csd, ext_csd, MMC_MAX_BLOCK_LEN);
#endif
- if (ext_csd[EXT_CSD_REV] >= ARRAY_SIZE(mmc_versions))
- return -EINVAL;
+ if (ext_csd[EXT_CSD_REV] >= ARRAY_SIZE(mmc_versions)) {
+ err = -EINVAL;
+ goto error;
+ }
mmc->version = mmc_versions[ext_csd[EXT_CSD_REV]];
---
base-commit: 7027b445cc0bfb86204ecb1f1fe596f5895048d9
change-id: 20250703-mmc_driver_fix-e798f1dae13e
Best regards,
--
Andrew Goodbody <andrew.goodbody at linaro.org>
More information about the U-Boot
mailing list