public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Xiubo Li <Li.Xiubo@freescale.com>
Cc: sameo@linux.intel.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mfd: core: Fix possible ZERO_SIZE_PTR pointer dereferencing error.
Date: Mon, 6 Oct 2014 22:14:43 +0100	[thread overview]
Message-ID: <20141006211443.GE18035@lee--X1> (raw)
In-Reply-To: <1411028499-44474-1-git-send-email-Li.Xiubo@freescale.com>

On Thu, 18 Sep 2014, Xiubo Li wrote:

> Since we cannot make sure the 'cell->num_resources' will always be none
> zero here, and then if either equal to zero, the kzalloc() will return
> ZERO_SIZE_PTR, which equals to ((void *)16).
> 
> So this patch fix this with just doing the zero check before calling
> kzalloc().
> 
> Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
> ---
>  drivers/mfd/mfd-core.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
> index 892d343..54c7e35 100644
> --- a/drivers/mfd/mfd-core.c
> +++ b/drivers/mfd/mfd-core.c
> @@ -89,6 +89,9 @@ static int mfd_add_device(struct device *parent, int id,
>  	int ret = -ENOMEM;
>  	int r;
>  
> +	if (!cell->num_resources)
> +		return -EINVAL;

Resources are not compulsory.

>  	pdev = platform_device_alloc(cell->name, id + cell->id);
>  	if (!pdev)
>  		goto fail_alloc;

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

      reply	other threads:[~2014-10-06 21:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-18  8:21 [PATCH] mfd: core: Fix possible ZERO_SIZE_PTR pointer dereferencing error Xiubo Li
2014-10-06 21:14 ` Lee Jones [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=20141006211443.GE18035@lee--X1 \
    --to=lee.jones@linaro.org \
    --cc=Li.Xiubo@freescale.com \
    --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