public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Anton Vorontsov <cbouatmailru@gmail.com>
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 0/2] base/platform: Platform data and resources NULL handling
Date: Tue, 7 Sep 2010 17:31:07 +0400	[thread overview]
Message-ID: <20100907133107.GA21463@oksana.dev.rtsoft.ru> (raw)

Hi all,

There is a bug in the MFD core code (drivers/mfd/mfd-core.c),
the mfd_add_device function does not check platform_data for NULL,
and thus always calls platform_device_add_data():

static int mfd_add_device(struct device *parent, int id, [...])
{
	[...]
	ret = platform_device_add_data(pdev,
		cell->platform_data, cell->data_size);
	[...]
}

The problem is that when cell->platform_data is NULL, the platform
core calls kmemdup(NULL, 0, ...), which returns a non-NULL result
(ZERO_SIZE_PTR), and the result is stored in the dev.platform_data.
This causes drivers to oops on a valid code:

if (pdata)
	stuff = pdata->stuff;

Firstly I thought that I would fix the MFD core, but it appears
that the better approach would be to change device_add_data() call
behaviour, and thus make the core code more safe.

There are two patches: a patch that is necessary for the bug fix,
and a non-essential cleanup patch.

Thanks,

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

             reply	other threads:[~2010-09-07 13:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-07 13:31 Anton Vorontsov [this message]
2010-09-07 13:31 ` [PATCH 1/2] base/platform: Safe handling for NULL platform data and resources Anton Vorontsov
2010-09-07 13:31 ` [PATCH 2/2] base/platform: Simplifications for NULL platform data/resources handling Anton Vorontsov

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=20100907133107.GA21463@oksana.dev.rtsoft.ru \
    --to=cbouatmailru@gmail.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sameo@linux.intel.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