summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinchan Kim <minchan@kernel.org>2020-10-10 23:16:37 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-10-14 11:55:59 +0200
commit0d600018dde7ab4ae6d9625daa45826acef6bd61 (patch)
tree874d24dd5fb7aac0cdcd0fcf22ae8b3ba44281a7
parent270974601ea5ad2e23cdd95b3a6e71e6a762eede (diff)
downloadlinux-0d600018dde7ab4ae6d9625daa45826acef6bd61.tar.gz
linux-0d600018dde7ab4ae6d9625daa45826acef6bd61.tar.bz2
linux-0d600018dde7ab4ae6d9625daa45826acef6bd61.zip
mm: validate inode in mapping_set_error()
commit 8b7b2eb131d3476062ffd34358785b44be25172f upstream. The swap address_space doesn't have host. Thus, it makes kernel crash once swap write meets error. Fix it. Fixes: 735e4ae5ba28 ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--include/linux/pagemap.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index cf2468da68e9..601ad6957bb9 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -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)