From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Roese Date: Mon, 12 Jan 2015 08:27:21 +0100 Subject: [U-Boot] [PATCH] cmd_sf: Fix problem with "sf update" and unaligned length In-Reply-To: <20150112071719.055CB38005C@gemini.denx.de> References: <1420810762-10712-1-git-send-email-sr@denx.de> <20150112071719.055CB38005C@gemini.denx.de> Message-ID: <54B37759.7040801@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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. Thanks, Stefan