From: Gerlando Falauto <gerlando.falauto@keymile.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] cmd_sf: Fix problem with "sf update" and unaligned length
Date: Mon, 12 Jan 2015 09:07:30 +0100 [thread overview]
Message-ID: <54B380C2.4050208@keymile.com> (raw)
In-Reply-To: <54B37759.7040801@denx.de>
Hi Wolfgang,
On 01/12/2015 08:27 AM, Stefan Roese wrote:
> Hi Wolfgang,
>
> On 12.01.2015 08:17, Wolfgang Denk wrote:
>>> The new code is even simpler and copies the source data into the temp
>>> buffer and now uses the temp buffer to write the complete sector. So
>>> only one SPI sector write is used now instead of 2 in the old version.
>> ...
>>
>>> if (len != flash->sector_size) {
>>> - /* Rewrite the original data to the end of the sector */
>>> - if (spi_flash_write(flash, offset + len,
>>> - flash->sector_size - len, &cmp_buf[len]))
>>> - return "write";
>>> + memcpy(cmp_buf, buf, len);
>>> + ptr = cmp_buf;
>>> }
>>
>> Should we add a memset(buf, 0, sizeof(buf)) before the memcpy() to
>> prevent information from earlier activities to leak?
>
> "buf" points to the new data to be written into the flash. We're
> overwriting the first "len" bytes of "cmp_buf" with this data.
>
> I don't see why we should erase anything there. Perhaps I'm missing
> something though.
That's right, and that's the whole point: cmp_buf points to the data
read from the flash sector before erasing it, because that's what we
want to keep (by re-writing it).
The first part, however, we overwrite with the new data (buf).
So there's nothing to erase.
Thanks,
Gerlando
next prev parent reply other threads:[~2015-01-12 8:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-09 13:39 [U-Boot] [PATCH] cmd_sf: Fix problem with "sf update" and unaligned length Stefan Roese
2015-01-12 7:17 ` Wolfgang Denk
2015-01-12 7:27 ` Stefan Roese
2015-01-12 8:07 ` Gerlando Falauto [this message]
2015-01-12 21:12 ` Wolfgang Denk
2015-01-12 21:10 ` Wolfgang Denk
2015-01-13 6:05 ` Stefan Roese
2015-04-22 11:11 ` Jagan Teki
2015-04-22 11:15 ` Stefan Roese
2015-04-22 11:26 ` Jagan Teki
2015-01-12 7:51 ` Gerlando Falauto
2015-01-12 7:56 ` Stefan Roese
2015-01-12 8:12 ` Gerlando Falauto
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=54B380C2.4050208@keymile.com \
--to=gerlando.falauto@keymile.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