dax: Check page->mapping isn't NULL

commit c93db7bb6e upstream.

If we race with inode destroy, it's possible for page->mapping to be
NULL before we even enter this routine, as well as after having slept
waiting for the dax entry to become unlocked.

Fixes: c2a7d2a115 ("filesystem-dax: Introduce dax_lock_mapping_entry()")
Cc: <stable@vger.kernel.org>
Reported-by: Jan Kara <jack@suse.cz>
Signed-off-by: Matthew Wilcox <willy@infradead.org>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Matthew Wilcox 2018-11-27 13:16:33 -08:00 committed by Greg Kroah-Hartman
parent 111758f735
commit 384f181152

View File

@ -423,7 +423,7 @@ bool dax_lock_mapping_entry(struct page *page)
for (;;) {
mapping = READ_ONCE(page->mapping);
if (!dax_mapping(mapping))
if (!mapping || !dax_mapping(mapping))
break;
/*