[U-Boot] [PATCH] part_dos: allocate sector buffer dynamically

Sergei Shtylyov sshtylyov at mvista.com
Tue May 3 14:20:16 CEST 2011


Hello.

On 30-04-2011 23:14, Wolfgang Denk wrote:

>> Apple iPod nanos have sector sizes of 2 or 4 KiB, which crashes U-Boot when it
>> tries to read the MBR into 512-byte buffer situated on stack. Instead allocate
>> this buffer dynamically to be safe with any large sector size.

>> Signed-off-by: Sergei Shtylyov<sshtylyov at ru.mvista.com>

> Can we please keep the buffer on the stack as before?

    It will be unsafe. We can't really predict the size of the buffer (unless 
we postulate that the buffer size won't ever exceed e.g. 4K).

> There is no need to use malloc() here.

    No, there *is* a need I think.

> It just makes the code slower and more
> complicated and error prone without neeed.

    I think using stack variables makes the code much more error prone, to the 
point that U-Boot just crashes when the sector size happens to exceed our 
buffer size.

> Best regards,

> Wolfgang Denk

WBR, Sergei


More information about the U-Boot mailing list