Skip to content

Commit c24de69

Browse files
osalvadorvilardagaSeth Forshee
authored andcommitted
mm/debug.c: fix __dump_page when mapping->host is not set
BugLink: https://bugs.launchpad.net/bugs/1823060 commit 5ae2efb upstream. While debugging something, I added a dump_page() into do_swap_page(), and I got the splat from below. The issue happens when dereferencing mapping->host in __dump_page(): ... else if (mapping) { pr_warn("%ps ", mapping->a_ops); if (mapping->host->i_dentry.first) { struct dentry *dentry; dentry = container_of(mapping->host->i_dentry.first, struct dentry, d_u.d_alias); pr_warn("name:\"%pd\" ", dentry); } } ... Swap address space does not contain an inode information, and so mapping->host equals NULL. Although the dump_page() call was added artificially into do_swap_page(), I am not sure if we can hit this from any other path, so it looks worth fixing it. We can easily do that by checking mapping->host first. Link: http://lkml.kernel.org/r/[email protected] Fixes: 1c6fb1d ("mm: print more information about mapping in __dump_page") Signed-off-by: Oscar Salvador <[email protected]> Acked-by: Michal Hocko <[email protected]> Acked-by: Hugh Dickins <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Seth Forshee <[email protected]>
1 parent 62d7db7 commit c24de69

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void __dump_page(struct page *page, const char *reason)
7979
pr_warn("ksm ");
8080
else if (mapping) {
8181
pr_warn("%ps ", mapping->a_ops);
82-
if (mapping->host->i_dentry.first) {
82+
if (mapping->host && mapping->host->i_dentry.first) {
8383
struct dentry *dentry;
8484
dentry = container_of(mapping->host->i_dentry.first, struct dentry, d_u.d_alias);
8585
pr_warn("name:\"%pd\" ", dentry);

0 commit comments

Comments
 (0)