From: Minchan Kim Date: Sun, 11 Oct 2020 06:16:37 +0000 (-0700) Subject: mm: validate inode in mapping_set_error() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=8b7b2eb131d3476062ffd34358785b44be25172f;p=linux.git mm: validate inode in mapping_set_error() 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 Signed-off-by: Andrew Morton Acked-by: Jeff Layton Cc: Jan Kara Cc: Andres Freund Cc: Matthew Wilcox Cc: Al Viro Cc: Christoph Hellwig Cc: Dave Chinner Cc: David Howells Cc: Link: https://lkml.kernel.org/r/20201010000650.750063-1-minchan@kernel.org Signed-off-by: Linus Torvalds --- diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 7de11dcd534d6..434c9c34aeb6e 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)