From: Simon Glass <simon.glass@canonical.com> If mmc_init() fails, the buffer allocated by calloc() or mapped by os_map_file() is not freed. Free or unmap the buffer before returning the error. Signed-off-by: Simon Glass <simon.glass@canonical.com> --- drivers/mmc/sandbox_mmc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/sandbox_mmc.c b/drivers/mmc/sandbox_mmc.c index a24520f2e78..f49cb4b146a 100644 --- a/drivers/mmc/sandbox_mmc.c +++ b/drivers/mmc/sandbox_mmc.c @@ -190,7 +190,16 @@ static int sandbox_mmc_probe(struct udevice *dev) } } - return mmc_init(&plat->mmc); + ret = mmc_init(&plat->mmc); + if (ret) { + if (plat->fname) + os_unmap(priv->buf, priv->size); + else + free(priv->buf); + return ret; + } + + return 0; } static int sandbox_mmc_remove(struct udevice *dev) -- 2.43.0