[BUG] Rewriting backing_dev_info in MTD

Jan Kara jack at suse.cz
Thu Apr 15 13:23:00 EDT 2010


On Tue 13-04-10 14:33:01, Kirill A. Shutemov wrote:
> I've got NULL-pointer dereference in __mark_inode_dirty() on chmod()
> for MTD device node. wb->bdi was NULL in this case.
> 
> During investigation I've found that MTD subsystem rewrites
> file->f_mapping->backing_dev_info on openning to get mmap() work on
> MMU-less systems. But in fact it rewrites
> inode->i_mapping->backing_dev_info too, since inode->i_mapping ==
> file->f_mapping (see __dentry_open() in fs/open.c). It breaks
> writeback of inode changes.
  I think the right trick is to not overwrite
file->f_mapping->backing_dev_info but rather change already
file->f_mapping. For example drivers/char/raw.c does this. Then you'll stop
having problems with writeback code going wild.

> I guess the right way to fix this is changing of __dentry_open() to
> create _copy_ of i_mapping to assign to f_mapping since in common case
> f_mapping != i_mapping. But I'm not sure were the copy should be
> freed.
  No, in most cases we will leave f_mapping == i_mapping so copying
i_mapping would be an overkill.

								Honza
-- 
Jan Kara <jack at suse.cz>
SUSE Labs, CR



More information about the linux-mtd mailing list