linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/writeback: fix dereferencing NULL mapping->host
@ 2022-11-29  3:32 Andrew Yang
  2022-11-29 14:56 ` Steven Rostedt
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Yang @ 2022-11-29  3:32 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu, Matthias Brugger
  Cc: Casper Li, andrew.yang, linux-kernel, linux-arm-kernel,
	linux-mediatek

From: "andrew.yang" <andrew.yang@mediatek.com>

Check before dereferencing mapping->host

Signed-off-by: andrew.yang <andrew.yang@mediatek.com>
---
 include/trace/events/writeback.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
index 86b2a82da546..56f6e114d3ed 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;
 	),
 
-- 
2.18.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mm/writeback: fix dereferencing NULL mapping->host
  2022-11-29  3:32 [PATCH] mm/writeback: fix dereferencing NULL mapping->host Andrew Yang
@ 2022-11-29 14:56 ` Steven Rostedt
  2022-11-30  8:23   ` [PATCH v2] " Andrew Yang
  0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2022-11-29 14:56 UTC (permalink / raw)
  To: Andrew Yang
  Cc: Masami Hiramatsu, Matthias Brugger, Casper Li, linux-kernel,
	linux-arm-kernel, linux-mediatek

On Tue, 29 Nov 2022 11:32:59 +0800
Andrew Yang <andrew.yang@mediatek.com> wrote:

> From: "andrew.yang" <andrew.yang@mediatek.com>
> 
> Check before dereferencing mapping->host
> 
> Signed-off-by: andrew.yang <andrew.yang@mediatek.com>
> ---
>  include/trace/events/writeback.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
> index 86b2a82da546..56f6e114d3ed 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;

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


>  		__entry->index = folio->index;
>  	),
>  


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] mm/writeback: fix dereferencing NULL mapping->host
  2022-11-29 14:56 ` Steven Rostedt
@ 2022-11-30  8:23   ` Andrew Yang
  2022-11-30  8:23     ` Andrew Yang
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Yang @ 2022-11-30  8:23 UTC (permalink / raw)
  To: rostedt
  Cc: andrew.yang, casper.li, linux-arm-kernel, linux-kernel,
	linux-mediatek, matthias.bgg, mhiramat

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 --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;
 	),
 
-- 
2.18.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] mm/writeback: fix dereferencing NULL mapping->host
  2022-11-30  8:23   ` [PATCH v2] " Andrew Yang
@ 2022-11-30  8:23     ` Andrew Yang
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Yang @ 2022-11-30  8:23 UTC (permalink / raw)
  To: rostedt
  Cc: andrew.yang, casper.li, linux-arm-kernel, linux-kernel,
	linux-mediatek, matthias.bgg, mhiramat

On Tue, 2022-11-29 at 09:56 -0500, Steven Rostedt wrote:
> On Tue, 29 Nov 2022 11:32:59 +0800
> Andrew Yang <andrew.yang@mediatek.com> wrote:
> 
> > From: "andrew.yang" <andrew.yang@mediatek.com>
> > 
> > Check before dereferencing mapping->host
> > 
> > Signed-off-by: andrew.yang <andrew.yang@mediatek.com>
> > ---
> >  include/trace/events/writeback.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/include/trace/events/writeback.h
> > b/include/trace/events/writeback.h
> > index 86b2a82da546..56f6e114d3ed 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;
> 
> 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
> 
> 
> >  		__entry->index = folio->index;
> >  	),
> >  
> 
> 
Sure, that's a good suggestion

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-30  8:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-29  3:32 [PATCH] mm/writeback: fix dereferencing NULL mapping->host Andrew Yang
2022-11-29 14:56 ` Steven Rostedt
2022-11-30  8:23   ` [PATCH v2] " Andrew Yang
2022-11-30  8:23     ` Andrew Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).