public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sshtylyov@mvista.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] part_dos: allocate sector buffer dynamically
Date: Tue, 03 May 2011 16:20:16 +0400	[thread overview]
Message-ID: <4DBFF300.9010906@mvista.com> (raw)
In-Reply-To: <20110430191454.978B9D5270F@gemini.denx.de>

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@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

  reply	other threads:[~2011-05-03 12:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-12 19:23 [U-Boot] [PATCH] part_dos: allocate sector buffer dynamically Sergei Shtylyov
2011-04-30 19:14 ` Wolfgang Denk
2011-05-03 12:20   ` Sergei Shtylyov [this message]
2011-05-03 12:34     ` Wolfgang Denk
2011-05-03 12:50       ` Sergei Shtylyov
2011-05-12 17:35         ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DBFF300.9010906@mvista.com \
    --to=sshtylyov@mvista.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox