Commit 97e012bb authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] ramfs o_sync oops fix

Writing to ramfs files with O_SYNC dereferences null in mpage_writepages(),
due to null a_ops->writepage.  The call path is

	generic_file_aio_write_nolock
	->generic_osync_inode
	  ->write_inode_now
	    ->__writeback_single_inode
	      ->__sync_single_inode
	        ->do_writepages
	          ->mpage_writepages

The best fix for this is to visit all ram-backed filesystems and give them a
no-op a_ops.writepages.  But baling out if the file is memory-backed is a
sufficient coverall and is how we handle this in __filemap_fdatawrite().
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a0f562df
......@@ -535,6 +535,9 @@ void write_inode_now(struct inode *inode, int sync)
.sync_mode = WB_SYNC_ALL,
};
if (inode->i_mapping->backing_dev_info->memory_backed)
return;
spin_lock(&inode_lock);
__writeback_single_inode(inode, &wbc);
spin_unlock(&inode_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment