Commit a3f5b14e authored by David Howells's avatar David Howells Committed by Linus Torvalds

[PATCH] Fix a NULL pointer bug in do_generic_file_read()

The attached patch fixes a bug introduced into do_generic_mapping_read() by
which a file pointer becomes required.  I'd arranged things so that the
file pointer was optional so that I could call the function directly on an
inode.
Signed-Off-By: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 9691cc0d
...@@ -699,13 +699,15 @@ EXPORT_SYMBOL(grab_cache_page_nowait); ...@@ -699,13 +699,15 @@ EXPORT_SYMBOL(grab_cache_page_nowait);
* *
* This is really ugly. But the goto's actually try to clarify some * This is really ugly. But the goto's actually try to clarify some
* of the logic when it comes to error handling etc. * of the logic when it comes to error handling etc.
* - note the struct file * is only passed for the use of readpage *
* Note the struct file* is only passed for the use of readpage. It may be
* NULL.
*/ */
void do_generic_mapping_read(struct address_space *mapping, void do_generic_mapping_read(struct address_space *mapping,
struct file_ra_state *_ra, struct file_ra_state *_ra,
struct file * filp, struct file *filp,
loff_t *ppos, loff_t *ppos,
read_descriptor_t * desc, read_descriptor_t *desc,
read_actor_t actor) read_actor_t actor)
{ {
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
...@@ -869,7 +871,8 @@ void do_generic_mapping_read(struct address_space *mapping, ...@@ -869,7 +871,8 @@ void do_generic_mapping_read(struct address_space *mapping,
*ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset; *ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset;
if (cached_page) if (cached_page)
page_cache_release(cached_page); page_cache_release(cached_page);
file_accessed(filp); if (filp)
file_accessed(filp);
} }
EXPORT_SYMBOL(do_generic_mapping_read); EXPORT_SYMBOL(do_generic_mapping_read);
......
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