All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: Take cleanup path to free memory on error exit
@ 2025-07-03 14:03 Andrew Goodbody
  2025-07-07  8:47 ` Peng Fan
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Goodbody @ 2025-07-03 14:03 UTC (permalink / raw)
  To: Peng Fan, Jaehoon Chung, Tom Rini, Tim Harvey; +Cc: u-boot, Andrew Goodbody

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@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@linaro.org>


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

* Re: [PATCH] mmc: Take cleanup path to free memory on error exit
  2025-07-03 14:03 [PATCH] mmc: Take cleanup path to free memory on error exit Andrew Goodbody
@ 2025-07-07  8:47 ` Peng Fan
  0 siblings, 0 replies; 2+ messages in thread
From: Peng Fan @ 2025-07-07  8:47 UTC (permalink / raw)
  To: Andrew Goodbody; +Cc: Peng Fan, Jaehoon Chung, Tom Rini, Tim Harvey, u-boot

On Thu, Jul 03, 2025 at 03:03:30PM +0100, Andrew Goodbody wrote:
>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@linaro.org>

Reviewed-by: Peng Fan <peng.fan@nxp.com>

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

end of thread, other threads:[~2025-07-07  7:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-03 14:03 [PATCH] mmc: Take cleanup path to free memory on error exit Andrew Goodbody
2025-07-07  8:47 ` Peng Fan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.