diff mbox series

[v2] mm/writeback: fix dereferencing NULL mapping->host

Message ID 20221130082303.30859-1-andrew.yang@mediatek.com (mailing list archive)
State New, archived
Headers show
Series [v2] mm/writeback: fix dereferencing NULL mapping->host | expand

Commit Message

Andrew Yang Nov. 30, 2022, 8:23 a.m. UTC
From: "andrew.yang" <andrew.yang@mediatek.com>

Check before dereferencing mapping->host

Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: andrew.yang <andrew.yang@mediatek.com>
---
v2: add parenthesis
---
 include/trace/events/writeback.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
index 86b2a82da546..54e353c9f919 100644
--- a/include/trace/events/writeback.h
+++ b/include/trace/events/writeback.h
@@ -68,7 +68,7 @@  DECLARE_EVENT_CLASS(writeback_folio_template,
 		strscpy_pad(__entry->name,
 			    bdi_dev_name(mapping ? inode_to_bdi(mapping->host) :
 					 NULL), 32);
-		__entry->ino = mapping ? mapping->host->i_ino : 0;
+		__entry->ino = (mapping && mapping->host) ? mapping->host->i_ino : 0;
 		__entry->index = folio->index;
 	),