RE: NOR read/write beyond end of flash partition

Tigadi Kiran-r10350c
2006-11-30T15:53:33Z

[-- Attachment #1: Type: text/plain, Size: 776 bytes --]

Hi Artem,

Please find attached patch for drivers/mtd/mtdchar.c file to fix NOR read beyond flash. Let me know whether it is valid fix.

Regards,
Kiran

-----Original Message-----
From: Artem Bityutskiy [mailto:dedekind@infradead.org]
Sent: Thursday, November 30, 2006 6:57 PM
To: Tigadi Kiran-r10350c
Cc: linux-mtd@lists.infradead.org
Subject: Re: NOR read/write beyond end of flash partition

Hello,

On Thu, 2006-11-30 at 18:45 +0530, Tigadi Kiran-r10350c wrote:
> But mtd_read routine implemented in the same file does not have this
> check. So when I try to read beyond end of NOR MTD partition it is
> returning 0.

Sounds like a bug, feel free to send a patch against mtd-2.6.git tree.

--
Best regards,
Artem Bityutskiy (Битюцкий Артём)

[-- Attachment #2: mtdchar_patch --]
[-- Type: application/octet-stream, Size: 305 bytes --]

--- drivers/mtd/mtdchar.c 2006-11-30 21:16:50.000000000 +0530
+++ drivers/mtd/mtdchar.new.c 2006-11-21 18:27:46.000000000 +0530
@@ -161,6 +161,9 @@

DEBUG(MTD_DEBUG_LEVEL0,"MTD_read\n");

+ if (*ppos == mtd->size)
+ return -ENOSPC;
+
if (*ppos + count > mtd->size)
count = mtd->size - *ppos;