mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Li.Xiubo@freescale.com" <Li.Xiubo@freescale.com>
To: Mark Brown <broonie@kernel.org>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] regmap: irq: Fix possible ZERO_SIZE_PTR pointer dereferencing error.
Date: Mon, 19 May 2014 23:51:26 +0000	[thread overview]
Message-ID: <a9148f4a1b3e4bab928365e455edf1cc@BY2PR03MB505.namprd03.prod.outlook.com> (raw)
In-Reply-To: <20140519161548.GZ12304@sirena.org.uk>

> Subject: Re: [PATCH] regmap: irq: Fix possible ZERO_SIZE_PTR pointer
> dereferencing error.
> 
> On Mon, May 19, 2014 at 03:13:45PM +0800, Xiubo Li wrote:
> > Since we cannot make sure the 'chip->num_regs' will always be none zero
> > from the users, and then if 'chip->num_regs' equals to zero by mistake
> > or other reasons, the kzalloc() will return ZERO_SIZE_PTR, which equals
> > to ((void *)16).
> >
> > So this patch fix this with just checking the 'chip->num_regs' before
> > calling kzalloc().
> 
> Where is the actual dereference that's being protected against here?
> 

Such as:
        d->mask_buf = kzalloc(sizeof(unsigned int) * chip->num_regs,
                              GFP_KERNEL);
        if (!d->mask_buf)
                goto err_alloc;

And then:
        d->mask_buf[irq_data->reg_offset / map->reg_stride] |= irq_data->mask;



> > This also sorts the header files in alphabetical order at the same time.
> 
> No, don't do things like this.  It just makes things harder to review.

Okay, I'll follow your advice.

Thanks,

BRs
Xiubo


  reply	other threads:[~2014-05-19 23:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-19  7:13 Xiubo Li
2014-05-19 16:15 ` Mark Brown
2014-05-19 23:51   ` Li.Xiubo [this message]
2014-05-26 15:37 ` 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=a9148f4a1b3e4bab928365e455edf1cc@BY2PR03MB505.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®