From d92ec071b211e0ee17496287f62652beb7db543d Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@nbd.name>
Date: Fri, 20 Apr 2018 10:02:28 +0200
Subject: [PATCH] mtd: fix erase handling with partition offset on write

When a partition offset is given, it is used in an lseek call, which
affects write, but not erase. Add it to the offset for erase calls as
well

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 package/system/mtd/src/mtd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/system/mtd/src/mtd.c b/package/system/mtd/src/mtd.c
index 55a3bdba81..fa04c0f95b 100644
--- a/package/system/mtd/src/mtd.c
+++ b/package/system/mtd/src/mtd.c
@@ -638,7 +638,7 @@ resume:
 					continue;
 				}
 
-				if (mtd_erase_block(fd, e) < 0) {
+				if (mtd_erase_block(fd, e + part_offset) < 0) {
 					if (next) {
 						if (w < e) {
 							write(fd, buf + offset, e - w);
-- 
2.30.2