diff mbox

[mtd-utils,10/11] flash_{un,}lock: don't allow "last byte + 1"

Message ID 1441060472-82169-11-git-send-email-computersforpeace@gmail.com
State Accepted
Commit ba224c47a1f71f01c0e65da85718247af91a5cc4
Headers show

Commit Message

Brian Norris Aug. 31, 2015, 10:34 p.m. UTC
A lock/unlock/islocked ioctl() should be prevented from anything past
the last byte, inclusive. But we were doing an exclusive check.

This isn't a big deal, as the kernel MTD APIs would be guarding this
anyway, but let's do this for completeness.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 flash_unlock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/flash_unlock.c b/flash_unlock.c
index 7a7a773d1d76..d775c0b01950 100644
--- a/flash_unlock.c
+++ b/flash_unlock.c
@@ -168,7 +168,7 @@  int main(int argc, char *argv[])
 	} else {
 		mtdLockInfo.start = 0;
 	}
-	if (mtdLockInfo.start > mtdInfo.size)
+	if (mtdLockInfo.start >= mtdInfo.size)
 		errmsg_die("%#x is beyond device size %#x",
 			mtdLockInfo.start, mtdInfo.size);