mm/writeback: fix dereferencing NULL mapping->host
Subsystems (3)
PATCH 1/1 mm/writeback: fix dereferencing NULL mapping->host
From: "andrew.yang" <[email protected]>
Check before dereferencing mapping->host
--- include/trace/events/writeback.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/trace/events/writeback.h +1 -1
@@ -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; ),
Signature · 1 line
2.18.0
Steven Rostedt
maintainerQuoted 14 lines · On Tue, 29 Nov 2022 11:32:59 +0800 Andrew Yang <[email protected]> wrote:
From: "andrew.yang" <[email protected]>
Check before dereferencing
mapping->hostSigned-off-by andrew.yang <[email protected]>--- include/trace/events/writeback.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/trace/events/writeback.h +0
-0
include/trace/events/writeback.h DECLARE_EVENT_CLASS(writeback_folio_template, · line 71
Quoted 5 lines
include/trace/events/writeback.h +1
-1@@ -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 ;
I hate remembering precedence. Can we add parenthesis around this to be clear?
__entry->ino = (mapping && mapping->host) ? mapping->host->i_ino : 0;
Thanks,
-- Steve
Quoted 3 lines
include/trace/events/writeback.h +0
-0__entry->index = folio->index; ),
PATCH v2 1/1 mm/writeback: fix dereferencing NULL mapping->host
From: "andrew.yang" <[email protected]>
Check before dereferencing mapping->host
---
v2: add parenthesis
--- include/trace/events/writeback.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/trace/events/writeback.h +1 -1
@@ -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; ),
Signature · 1 line
2.18.0
Quoted 30 lines · Steven Rostedt
Quoted 21 lines · On Tue, 29 Nov 2022 11:32:59 +0800 Andrew Yang <[email protected]> wrote:
From: "andrew.yang" <[email protected]>
Check before dereferencing
mapping->hostSigned-off-by andrew.yang <[email protected]>--- include/trace/events/writeback.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/trace/events/writeback.h +0
-0@@ -68,7 +68,7 @@ DECLARE_EVENT_CLASS(writeback_folio_template, strscpy_pad(__entry->name, bdi_dev_name(mapping ?
inode_to_bdi(mapping->host):include/trace/events/writeback.h +1
-1NULL), 32); - __entry->ino = mapping ? mapping->host->i_ino :0 ; + __entry->ino = mapping && mapping->host ? mapping-Quoted 1 line
Quoted 1 line
host->i_ino: 0;I hate remembering precedence. Can we add parenthesis around this to be
clear?
Quoted 13 lines
__entry->ino = (mapping && mapping->host) ? mapping-Quoted 1 line
host->i_ino: 0;Thanks,
-- Steve
Quoted 3 lines
include/trace/events/writeback.h +0
-0__entry->index = folio->index; ),
Sure, that's a good suggestion