diff mbox

[U-Boot] cmd/onenand.c: block align warning

Message ID 20160913054000.GA1917@localhost.localdomain
State Accepted
Commit 9c00d982f1d18fd1e8ed586dc1c041988aba4567
Delegated to: Tom Rini
Headers show

Commit Message

Ladislav Michl Sept. 13, 2016, 5:40 a.m. UTC
An attempt to write non block aligned data fails silently, add warning and
set result.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
---
 cmd/onenand.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Tom Rini Oct. 8, 2016, 5:05 p.m. UTC | #1
On Tue, Sep 13, 2016 at 07:40:00AM +0200, Ladislav Michl wrote:

> An attempt to write non block aligned data fails silently, add warning and
> set result.
> 
> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/cmd/onenand.c b/cmd/onenand.c
index feab01a..090f835 100644
--- a/cmd/onenand.c
+++ b/cmd/onenand.c
@@ -139,6 +139,12 @@  static int onenand_block_write(loff_t to, size_t len,
 	size_t _retlen = 0;
 	int ret;
 
+	if ((to & (mtd->writesize - 1)) != 0) {
+		printf("Attempt to write non block-aligned data\n");
+		*retlen = 0;
+		return 1;
+	}
+
 	if (to == next_ofs) {
 		next_ofs = to + len;
 		to += skip_ofs;