mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-04 09:59:32 +00:00
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: 735e4ae5ba
("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>
This commit is contained in:
parent
bc4fe4cdd6
commit
8b7b2eb131
1 changed files with 2 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue