public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* Possible bug in /proc/mtd ?
@ 2002-03-06 15:44 Steve Wahl
  2002-03-07 18:25 ` Jörn Engel
  0 siblings, 1 reply; 2+ messages in thread
From: Steve Wahl @ 2002-03-06 15:44 UTC (permalink / raw)
  To: linux-mtd

I've just started to bring up MTD in a uC-linux derived system.

I've found what I believe is a problem in the code for /proc/mtd.

Does anyone else get some sort of strange behavior if they run:

	dd if=/proc/mtd of=/dev/tty bs=1

The strange behavior on my system is a hang; it may be an oops or
panic of some sort on a system with a mmu.

If you see this problem, I think it should go away with this patch:


------------------------------------------------------------
--- mtdcore.c	22 Nov 2001 05:29:30 -0000	1.2
+++ mtdcore.c	6 Mar 2002 15:40:55 -0000
@@ -289,21 +289,21 @@
         }
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
         *eof = 1;
 #endif
 
 done:
 	up(&mtd_table_mutex);
         if (off >= len+begin)
                 return 0;
-        *start = page + (begin-off);
+        *start = page + (off-begin);
         return ((count < begin+len-off) ? count : begin+len-off);
 }
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,0)
 struct proc_dir_entry mtd_proc_entry = {
         0,                 /* low_ino: the inode -- dynamic */
         3, "mtd",     /* len of name and name */
         S_IFREG | S_IRUGO, /* mode */
         1, 0, 0,           /* nlinks, owner, group */
         0, NULL,           /* size - unused; operations -- use default */
------------------------------------------------------------

Thanks for looking,

--> Steve Wahl

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Possible bug in /proc/mtd ?
  2002-03-06 15:44 Possible bug in /proc/mtd ? Steve Wahl
@ 2002-03-07 18:25 ` Jörn Engel
  0 siblings, 0 replies; 2+ messages in thread
From: Jörn Engel @ 2002-03-07 18:25 UTC (permalink / raw)
  To: Steve Wahl; +Cc: linux-mtd

Hi!

> Does anyone else get some sort of strange behavior if they run:
> 
> 	dd if=/proc/mtd of=/dev/tty bs=1
> 
> The strange behavior on my system is a hang; it may be an oops or
> panic of some sort on a system with a mmu.
>
> [...]
> 
> -        *start = page + (begin-off);
> +        *start = page + (off-begin);

Pretty obvious. You must be the first one to ever try that. :-)

David, is it ok, if I apply?

Jörn

-- 
When in doubt, use brute force.
-- Ken Thompson

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-03-07 18:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-03-06 15:44 Possible bug in /proc/mtd ? Steve Wahl
2002-03-07 18:25 ` Jörn Engel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox