]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm: validate inode in mapping_set_error()
authorMinchan Kim <minchan@kernel.org>
Sun, 11 Oct 2020 06:16:37 +0000 (23:16 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 11 Oct 2020 17:31:10 +0000 (10:31 -0700)
The swap address_space doesn't have host. Thus, it makes kernel crash once
swap write meets error. Fix it.

Fixes: b39c9cab1f58 ("vfs: track per-sb writeback errors and report them to syncfs")
Signed-off-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Jeff Layton <jlayton@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Andres Freund <andres@anarazel.de>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Dave Chinner <david@fromorbit.com>
Cc: David Howells <dhowells@redhat.com>
Cc: <stable@vger.kernel.org>
Link: https://lkml.kernel.org/r/20201010000650.750063-1-minchan@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/pagemap.h

index 7de11dcd534d6fdb171c382bf14e896ca0e6b5c3..434c9c34aeb6e12df15942f1272587f7ad087cc8 100644 (file)
@@ -54,7 +54,8 @@ static inline void mapping_set_error(struct address_space *mapping, int error)
        __filemap_set_wb_err(mapping, error);
 
        /* Record it in superblock */
-       errseq_set(&mapping->host->i_sb->s_wb_err, error);
+       if (mapping->host)
+               errseq_set(&mapping->host->i_sb->s_wb_err, error);
 
        /* Record it in flags for now, for legacy callers */
        if (error == -ENOSPC)