public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Pawel Moll <pawel.moll@arm.com>
To: Dan Carpenter <dan.carpenter@oracle.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 09:22:22 +0000	[thread overview]
Message-ID: <1402478542.3523.9.camel@hornet> (raw)
In-Reply-To: <20140611060725.GC7569@mwanda>

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)) {                                

Pawel


  reply	other threads:[~2014-06-11  9:22 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 [this message]
2014-06-11 10:07   ` Dan Carpenter
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=1402478542.3523.9.camel@hornet \
    --to=pawel.moll@arm.com \
    --cc=arnd@arndb.de \
    --cc=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lee.jones@linaro.org \
    --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