public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Samuel Ortiz <sameo@linux.intel.com>
To: Brian Harring <ferringb@gmail.com>
Cc: linux-kernel@vger.kernel.org, richard.rojfors@pelagicore.com
Subject: Re: [PATCH] add platform_data only if non NULL
Date: Tue, 19 Oct 2010 01:25:02 +0200	[thread overview]
Message-ID: <20101018232501.GA16761@sortiz-mobl> (raw)
In-Reply-To: <20101004015056.GA22095@hrair>

Hi Brian,

On Sun, Oct 03, 2010 at 06:50:56PM -0700, Brian Harring wrote:
> If a NULL or 0 size platform_data is added, the underlying dup results in a pointer into nullspace- meaning drivers can't do null checks for platform_data.
> 
> This fixes an oops during probing for drivers/net/ks8842, and drivers/mmc/host/sdhci-pltform when the mfd is timberdale
> 
Patch applied, without the paranoid setting :) Many thanks.

Cheers,
Samuel.


> Signed-off-by: Brian Harring <ferringb@gmail.com>
> ---
>  drivers/mfd/mfd-core.c |   13 +++++++++----
>  1 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
> index 1823a57..eee73a8 100644
> --- a/drivers/mfd/mfd-core.c
> +++ b/drivers/mfd/mfd-core.c
> @@ -38,10 +38,15 @@ static int mfd_add_device(struct device *parent, int id,
>  	pdev->dev.parent = parent;
>  	platform_set_drvdata(pdev, cell->driver_data);
>  
> -	ret = platform_device_add_data(pdev,
> -			cell->platform_data, cell->data_size);
> -	if (ret)
> -		goto fail_res;
> +	if (cell->data_size) {
> +		ret = platform_device_add_data(pdev,
> +				cell->platform_data, cell->data_size);
> +		if (ret)
> +			goto fail_res;
> +	} else {
> +		/* potentially nulled already, just being paranoid. */
> +		pdev->dev.platform_data = NULL;
> +	}
>  
>  	for (r = 0; r < cell->num_resources; r++) {
>  		res[r].name = cell->resources[r].name;
> -- 
> 1.7.2
> 



-- 
Intel Open Source Technology Centre
http://oss.intel.com/

      reply	other threads:[~2010-10-18 23:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-04  1:50 [PATCH] add platform_data only if non NULL Brian Harring
2010-10-18 23:25 ` Samuel Ortiz [this message]

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=20101018232501.GA16761@sortiz-mobl \
    --to=sameo@linux.intel.com \
    --cc=ferringb@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=richard.rojfors@pelagicore.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