]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm/shmem.c: don't run init_page_accessed() against an uninitialised pointer
authorAndrew Morton <akpm@linux-foundation.org>
Thu, 22 May 2014 00:43:22 +0000 (10:43 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 22 May 2014 00:43:22 +0000 (10:43 +1000)
If shmem_getpage() returned an error then it didn't necessarily initialise
*pagep.  So shmem_write_begin() shouldn't be playing with *pagep in this
situation.

Fixes an oops when "mm: non-atomically mark page accessed during page
cache allocation where possible" (quite reasonably) left *pagep
uninitialized.

Reported-by: Prabhakar Lad <prabhakar.csengg@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Jan Kara <jack@suse.cz>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Dave Hansen <dave.hansen@intel.com>
Acked-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/shmem.c

index 700a4adc57c1765293abd13854fed55ab8db1413..5402481c28d190a83718f6b1897eec78df4c0209 100644 (file)
@@ -1376,7 +1376,7 @@ shmem_write_begin(struct file *file, struct address_space *mapping,
        struct inode *inode = mapping->host;
        pgoff_t index = pos >> PAGE_CACHE_SHIFT;
        ret = shmem_getpage(inode, index, pagep, SGP_WRITE, NULL);
-       if (*pagep)
+       if (ret == 0 && *pagep)
                init_page_accessed(*pagep);
        return ret;
 }