mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Li.Xiubo@freescale.com" <Li.Xiubo@freescale.com>
To: "broonie@kernel.org" <broonie@kernel.org>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] regmap: fix possible ZERO_SIZE_PTR pointer dereferencing error.
Date: Sun, 28 Sep 2014 09:25:06 +0000	[thread overview]
Message-ID: <e0bb202c7b9c4384afa244f2f6165aa8@BY2PR0301MB0613.namprd03.prod.outlook.com> (raw)
In-Reply-To: <1411895394-25250-1-git-send-email-Li.Xiubo@freescale.com>

Hi Mark,


> Subject: [PATCH] regmap: fix possible ZERO_SIZE_PTR pointer dereferencing
> error.
> 
> Since we cannot make sure the 'val_count' will always be none zero
> here, and then if it equals to zero, the kmemdup() will return
> ZERO_SIZE_PTR, which equals to ((void *)16).
> 
> So this patch fix this with just doing the zero check before calling
> kmemdup().
> 
> Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
> ---
>  drivers/base/regmap/regmap.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
> index 455a877..3d93e38 100644
> --- a/drivers/base/regmap/regmap.c
> +++ b/drivers/base/regmap/regmap.c
> @@ -1716,6 +1716,9 @@ out:
>  	} else {
>  		void *wval;
> 
> +		if (!val_count)
> +			return -EINVAL;
> +

Should it return zero as success or just return -EINVAL for error here ?

If it allow zero of val_count in regmap_bulk_write(..., val_count) could do
Nothing and just return zero as success at the beginning of it.

I will respin this patch if return zero is better ...

Thanks,

BRs
Xiubo

>  		wval = kmemdup(val, val_count * val_bytes, GFP_KERNEL);
>  		if (!wval) {
>  			dev_err(map->dev, "Error in memory allocation\n");
> --
> 2.1.0.27.g96db324


  reply	other threads:[~2014-09-28  9:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-28  9:09 Xiubo Li
2014-09-28  9:25 ` Li.Xiubo [this message]
2014-09-28 10:56 ` Mark Brown
2014-09-30  5:05   ` Li.Xiubo
  -- strict thread matches above, loose matches on Subject: below --
2014-04-30  9:31 [PATCH] regmap: Fix " Xiubo Li
2014-05-01  3:34 ` Mark Brown

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=e0bb202c7b9c4384afa244f2f6165aa8@BY2PR0301MB0613.namprd03.prod.outlook.com \
    --to=li.xiubo@freescale.com \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®