]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Fix a NULL pointer bug in do_generic_file_read()
authorDavid Howells <dhowells@redhat.com>
Tue, 31 Aug 2004 03:38:57 +0000 (20:38 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 31 Aug 2004 03:38:57 +0000 (20:38 -0700)
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 <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
mm/filemap.c

index 36e34ed27657ad8bc808dcd69a06a8e218a28d38..dfbc5e093b669219072785a6776a0de1ff6b4b22 100644 (file)
@@ -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);