public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Shuah Khan <shuah.kh@samsung.com>
To: anton@enomsg.org, dwmw2@infradead.org, rostedt@goodmis.org,
	fweisbec@gmail.com, mingo@redhat.com, rjw@rjwysocki.net,
	gregkh@linuxfoundation.org
Cc: Shuah Khan <shuah.kh@samsung.com>,
	linux-kernel@vger.kernel.org, shuahkhan@gmail.com
Subject: [PATCH v3 0/2] power_supply: Fix Oops from NULL pointer dereference from wakeup_source_activate
Date: Fri, 22 Nov 2013 10:54:27 -0700	[thread overview]
Message-ID: <cover.1385138418.git.shuah.kh@samsung.com> (raw)

power_supply_register() calls device_init_wakeup() to register a wakeup
source before initializing dev_name. As a result, device_wakeup_enable()
end up registering wakeup source with a null name when wakeup_source_register()
gets called with dev_name(dev) which is null at the time.

device_wakeup_enable() uses dev_name(dev) as the wakeup source name.
When it gets called with a device with its name not yet set, ws structure
with ws->name = NULL gets created.

When kernel is booted with wakeup_source_activate enabled, it will panic
when the trace point code tries to dereference ws->name. Registering a
a wakeup source without a name should be possible.

This patch series fixes power_supply_register() to initialize the device name
prior to calling device_init_wakeup() and fixes tracing infrastructure to be
more robust in handling null strings in __assign_string() and __string(). With
this change null string is handled gracefully and replacing it with "(null)"
when trace is generated.

These two patches are not dependent, I left them as a series since the original
discussion started the fixes grouped in a series.

power_supply patch - no changes since series patch v1, other than including
Acked-by from Greg and Anton. Also added stable tag.

Second patch now is the fix to tracepoint infrastructure routines
__assign_string() and __string(). This will address the problem at the tracing
infrastructure level which is better than fixing individual tracepoint code.

These patches can be applied independently with no ill effects. I included
the trace for the wakeup_source_activate trace output in the change logs for
both patches.

Shuah Khan (2):
  power_supply: Fix Oops from NULL pointer dereference from
    wakeup_source_activate
  tracing: Fix Oops from NULL pointer dereference from __assign_str

 drivers/power/power_supply_core.c | 12 ++++++------
 include/trace/ftrace.h            |  7 +++++--
 2 files changed, 11 insertions(+), 8 deletions(-)

-- 
1.8.3.2


             reply	other threads:[~2013-11-22 17:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-22 17:54 Shuah Khan [this message]
2013-11-22 17:54 ` [PATCH v3 1/2] power_supply: Fix Oops from NULL pointer dereference from wakeup_source_activate Shuah Khan
2013-12-01 21:50   ` Anton Vorontsov
2013-11-22 17:54 ` [PATCH v3 2/2] tracing: Fix Oops from NULL pointer dereference from __assign_str Shuah Khan
2013-11-22 22:18   ` Rafael J. Wysocki
2013-11-26 14:46     ` Steven Rostedt
2013-11-26 15:07       ` 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=cover.1385138418.git.shuah.kh@samsung.com \
    --to=shuah.kh@samsung.com \
    --cc=anton@enomsg.org \
    --cc=dwmw2@infradead.org \
    --cc=fweisbec@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rjw@rjwysocki.net \
    --cc=rostedt@goodmis.org \
    --cc=shuahkhan@gmail.com \
    /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