public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Pawel Moll <pawel.moll@arm.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Lee Jones <lee.jones@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>
Subject: Re: [patch] mfd: vexpress: use after free in vexpress_syscfg_regmap_init()
Date: Wed, 11 Jun 2014 13:07:52 +0300	[thread overview]
Message-ID: <20140611100752.GR5500@mwanda> (raw)
In-Reply-To: <1402478542.3523.9.camel@hornet>

On Wed, Jun 11, 2014 at 10:22:22AM +0100, Pawel Moll wrote:
> On Wed, 2014-06-11 at 07:07 +0100, Dan Carpenter wrote:
> > We should return NULL if regmap_init() fails instead of continuing.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > diff --git a/drivers/misc/vexpress-syscfg.c b/drivers/misc/vexpress-syscfg.c
> > index 73068e5..2c0ddb2 100644
> > --- a/drivers/misc/vexpress-syscfg.c
> > +++ b/drivers/misc/vexpress-syscfg.c
> > @@ -231,10 +231,12 @@ static struct regmap *vexpress_syscfg_regmap_init(struct device *dev,
> >  	func->regmap = regmap_init(dev, NULL, func,
> >  			&vexpress_syscfg_regmap_config);
> >  
> > -	if (IS_ERR(func->regmap))
> > +	if (IS_ERR(func->regmap)) {
> >  		kfree(func);
> > -	else
> > -		list_add(&func->list, &syscfg->funcs);
> > +		return NULL;
> > +	}
> > +
> > +	list_add(&func->list, &syscfg->funcs);
> >  
> >  	return func->regmap;
> >  }
> 
> Not really, no. What made you think so?
> 
> vexpress_config_bridge_ops.regmap_init should return an ERR_PTR in case
> of troubles, not a NULL. See devm_regmap_init_vexpress_config() in
> drivers/bus/vexpress-config.c:
> 
>         regmap = bridge->ops->regmap_init(dev, bridge->context);
>         if (IS_ERR(regmap)) {

Ah...  That was sloppy of me.  There is a similar bug earlier and I'll
fix that as well.

regards,
dan carpenter


  reply	other threads:[~2014-06-11 10:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-11  6:07 [patch] mfd: vexpress: use after free in vexpress_syscfg_regmap_init() Dan Carpenter
2014-06-11  9:22 ` Pawel Moll
2014-06-11 10:07   ` Dan Carpenter [this message]
2014-06-11 10:17   ` [patch v2] mfd: vexpress: fix error handling vexpress_syscfg_regmap_init() Dan Carpenter
2014-06-11 10:33     ` Pawel Moll
2014-06-11 17:12       ` Greg Kroah-Hartman
2014-06-11 17:11         ` Pawel Moll
2014-06-13 14:02       ` Arnd Bergmann

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=20140611100752.GR5500@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pawel.moll@arm.com \
    --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