From: Steven Rostedt <rostedt@goodmis.org>
To: shuah.kh@samsung.com
Cc: len.brown@intel.com, pavel@ucw.cz, rjw@rjwysocki.net,
gregkh@linuxfoundation.org, anton@enomsg.org,
dwmw2@infradead.org, fweisbec@gmail.com, mingo@redhat.com,
keun-o.park@windriver.com, paul.gortmaker@windriver.com,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
shuahkhan@gmail.com, stable@vger.kernel.org
Subject: Re: [PATCH 2/2] PM: Fix Oops from NULL pointer dereference in wakeup_source_activate
Date: Wed, 20 Nov 2013 21:26:56 -0500 [thread overview]
Message-ID: <20131120212656.1df4515e@gandalf.local.home> (raw)
In-Reply-To: <528D6972.9010702@samsung.com>
On Wed, 20 Nov 2013 19:01:22 -0700
Shuah Khan <shuah.kh@samsung.com> wrote:
> On 11/20/2013 06:40 PM, Shuah Khan wrote:
> > ---
> > include/trace/events/power.h | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/trace/events/power.h b/include/trace/events/power.h
> > index cda100d..5ba545a 100644
> > --- a/include/trace/events/power.h
> > +++ b/include/trace/events/power.h
> > @@ -110,12 +110,14 @@ DECLARE_EVENT_CLASS(wakeup_source,
> > TP_ARGS(name, state),
> >
> > TP_STRUCT__entry(
> > - __string( name, name )
> > + __string(name, name ? name : "(no name)")
> > __field( u64, state )
> > ),
> >
> > TP_fast_assign(
> > - __assign_str(name, name);
> > + const char *tname = name ? name : "(no name)";
> > +
> > + __assign_str(name, tname);
> > __entry->state = state;
> > ),
> >
> >
>
> Adding tracing maintainers.
Thanks!
This is one solution, but what about just making the tracing facility a
bit more robust for everyone. Following what glibc printf() does when
it is passed a NULL, does this patch fix it too?
-- Steve
(haven't even compile tested this)
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 52594b2..bdac88c 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -372,7 +372,8 @@ ftrace_define_fields_##call(struct ftrace_event_call *event_call) \
__data_size += (len) * sizeof(type);
#undef __string
-#define __string(item, src) __dynamic_array(char, item, strlen(src) + 1)
+#define __string(item, src) __dynamic_array(char, item, \
+ strlen((src) ? (src) : "(null)") + 1)
#undef DECLARE_EVENT_CLASS
#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \
@@ -501,7 +502,7 @@ static inline notrace int ftrace_get_offsets_##call( \
#undef __assign_str
#define __assign_str(dst, src) \
- strcpy(__get_str(dst), src);
+ strcpy(__get_str(dst), (src) ? (src) : "(null)");
#undef TP_fast_assign
#define TP_fast_assign(args...) args
next prev parent reply other threads:[~2013-11-21 2:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-21 1:40 [PATCH 0/2] power_supply: Fix Oops from NULL pointer dereference from wakeup_source_activate Shuah Khan
2013-11-21 1:40 ` [PATCH 1/2] " Shuah Khan
2013-11-21 1:40 ` [PATCH 2/2] PM: Fix Oops from NULL pointer dereference in wakeup_source_activate Shuah Khan
2013-11-21 2:01 ` Shuah Khan
2013-11-21 2:26 ` Steven Rostedt [this message]
2013-11-21 18:02 ` Shuah Khan
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=20131120212656.1df4515e@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=anton@enomsg.org \
--cc=dwmw2@infradead.org \
--cc=fweisbec@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=keun-o.park@windriver.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=paul.gortmaker@windriver.com \
--cc=pavel@ucw.cz \
--cc=rjw@rjwysocki.net \
--cc=shuah.kh@samsung.com \
--cc=shuahkhan@gmail.com \
--cc=stable@vger.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).