Skip to contentSkip to conversation

Issue in drivers/mmc/mmc.c

U-Boot Quentin Armitage 2 participants 3 messages Jan 3, 2010 – Mar 11, 2010 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

There appears to be a path through mmc_read in drivers/mmc/mmc.c where malloc'd memory is not freed before exiting mmc_read, although this may be a hypothetical situation. It occurs if mmc_set_blocklen() returns a non-zero value.

The following patch appears to resolve the issue:

mmc/mmc.c renamed from drivers/mmc/mmc.c +1 -1
@@ -172,7 +172,7 @@ int mmc_read(struct mmc *mmc, u64 src, u
 	err = mmc_set_blocklen(mmc, mmc->read_bl_len);
 
 	if (err)
-		return err;
+		goto free_buffer;
 
 	for (i = startblock; i <= endblock; i++) {
 		int segment_size;

Regards,
Quentin Armitage

#1 lore raw

Dear Quentin Armitage,

Quoted 10 lines · In message <[email protected]> you wrote:

There appears to be a path through mmc_read in drivers/mmc/mmc.c where malloc'd memory is not freed before exiting mmc_read, although this may be a hypothetical situation. It occurs if mmc_set_blocklen() returns a non-zero value.

The following patch appears to resolve the issue:

mmc/mmc.c int mmc_read(struct mmc *mmc, u64 src, u · line 178

Quoted 8 lines
mmc/mmc.c renamed from drivers/mmc/mmc.c +1 -1
@@ -172,7 +172,7 @@ int mmc_read(struct mmc *mmc, u64 src, u
 	err = mmc_set_blocklen(mmc, mmc->read_bl_len);
 
 	if (err)
-		return err;
+		goto free_buffer;
 
 	for (i = startblock; i <= endblock; i++) {
 		int segment_size;

Can you please resent this patch, with your Signed-off-by: line added?

See http://www.denx.de/wiki/U-Boot/Patches for details. Thanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"The more data I punch in this card,  the lighter it becomes, and the
lower the mailing cost."
                     - Stan Kelly-Bootle, "The Devil's DP Dictionary"
#2 lore raw
In reply to Quentin Armitage

Dear Quentin Armitage,

Quoted 10 lines · In message <[email protected]> you wrote:

There appears to be a path through mmc_read in drivers/mmc/mmc.c where malloc'd memory is not freed before exiting mmc_read, although this may be a hypothetical situation. It occurs if mmc_set_blocklen() returns a non-zero value.

The following patch appears to resolve the issue:

mmc/mmc.c int mmc_read(struct mmc *mmc, u64 src, u · line 178

Quoted 8 lines
mmc/mmc.c renamed from drivers/mmc/mmc.c +1 -1
@@ -172,7 +172,7 @@ int mmc_read(struct mmc *mmc, u64 src, u
 	err = mmc_set_blocklen(mmc, mmc->read_bl_len);
 
 	if (err)
-		return err;
+		goto free_buffer;
 
 	for (i = startblock; i <= endblock; i++) {
 		int segment_size;

As you did not follow up on my request to repostwith you SoB-line added I went ahead and added the fix myself. Thanks for reporting it.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
No question is too silly to ask. Of course, some  questions  are  too
silly to to answer...  - L. Wall & R. L. Schwartz, _Programming Perl_