From a3f5b14ed7a7e9d524b05db64b6a26911ec95a2b Mon Sep 17 00:00:00 2001 From: David Howells Date: Mon, 30 Aug 2004 20:38:57 -0700 Subject: [PATCH] [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: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/filemap.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 36e34ed27657a..dfbc5e093b669 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -699,13 +699,15 @@ EXPORT_SYMBOL(grab_cache_page_nowait); * * This is really ugly. But the goto's actually try to clarify some * 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, struct file_ra_state *_ra, - struct file * filp, + struct file *filp, loff_t *ppos, - read_descriptor_t * desc, + read_descriptor_t *desc, read_actor_t actor) { struct inode *inode = mapping->host; @@ -869,7 +871,8 @@ out: *ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset; if (cached_page) page_cache_release(cached_page); - file_accessed(filp); + if (filp) + file_accessed(filp); } EXPORT_SYMBOL(do_generic_mapping_read); -- 2.53.0