linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sasha.levin@oracle.com>
To: rostedt@goodmis.org, mingo@redhat.com
Cc: axboe@fb.com, tj@kernel.org, linux-kernel@vger.kernel.org,
	Sasha Levin <sasha.levin@oracle.com>
Subject: [PATCH] writeback: verify that underlying dev exists before getting its name
Date: Fri,  4 Sep 2015 12:45:18 -0400	[thread overview]
Message-ID: <1441385118-27199-1-git-send-email-sasha.levin@oracle.com> (raw)

We can't assume there is always an underlying device and must verify that
as well. Otherwise, we'd deref a NULL ptr here.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 include/trace/events/writeback.h |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
index fff846b..8f9efaa 100644
--- a/include/trace/events/writeback.h
+++ b/include/trace/events/writeback.h
@@ -66,7 +66,9 @@ TRACE_EVENT(writeback_dirty_page,
 
 	TP_fast_assign(
 		strncpy(__entry->name,
-			mapping ? dev_name(inode_to_bdi(mapping->host)->dev) : "(unknown)", 32);
+			mapping && inode_to_bdi(mapping->host)->dev ?
+				dev_name(inode_to_bdi(mapping->host)->dev) :
+				"(unknown)", 32);
 		__entry->ino = mapping ? mapping->host->i_ino : 0;
 		__entry->index = page->index;
 	),
-- 
1.7.10.4


             reply	other threads:[~2015-09-04 16:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-04 16:45 Sasha Levin [this message]
2015-09-04 16:47 ` [PATCH] writeback: verify that underlying dev exists before getting its name Tejun Heo
2015-09-04 17:20   ` Sasha Levin
2015-09-04 17:36     ` Tejun Heo
2015-09-09 18:32       ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1441385118-27199-1-git-send-email-sasha.levin@oracle.com \
    --to=sasha.levin@oracle.com \
    --cc=axboe@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).