linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: Cong Ding <dinggnu@gmail.com>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>,
	Kyungmin Park <kmpark@infradead.org>,
	Wolfram Sang <w.sang@pengutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Karol Lewandowski <k.lewandowsk@samsung.com>,
	Haojian Zhuang <haojian.zhuang@marvell.com>,
	linux-i2c@vger.kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] i2c: busses/i2c-pxa.c: fix potential null pointer dereference error
Date: Thu, 21 Mar 2013 11:54:29 +0100	[thread overview]
Message-ID: <20130321105429.GE19297@the-dreams.de> (raw)
In-Reply-To: <20130214112818.GA18774@gmail.com>

On Thu, Feb 14, 2013 at 12:28:18PM +0100, Cong Ding wrote:
> If it goes to eclk through line 1107, the variable res would be NULL. It will
> cause a null pointer dereference error if we call release_mem_region. The
> correct way should be using devm_kzalloc rather than kzalloc to allocate
> memory.
> 
> Signed-off-by: Cong Ding <dinggnu@gmail.com>
> ---
>  drivers/i2c/busses/i2c-pxa.c |   22 ++++++++--------------
>  1 file changed, 8 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
> index 1034d93..dd2d640 100644
> --- a/drivers/i2c/busses/i2c-pxa.c
> +++ b/drivers/i2c/busses/i2c-pxa.c
> @@ -1094,29 +1094,23 @@ static int i2c_pxa_probe(struct platform_device *dev)
>  	struct resource *res = NULL;
>  	int ret, irq;
>  
> -	i2c = kzalloc(sizeof(struct pxa_i2c), GFP_KERNEL);
> -	if (!i2c) {
> -		ret = -ENOMEM;
> -		goto emalloc;
> -	}
> +	i2c = devm_kzalloc(sizeof(struct pxa_i2c), GFP_KERNEL);

You are using devm_kzalloc here but plain kfree is used later. This
won't work.

      parent reply	other threads:[~2013-03-21 10:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-04 22:11 [PATCH] i2c: busses/i2c-pxa.c: fix potential null pointer dereference error Cong Ding
2013-02-04 23:47 ` Kyungmin Park
     [not found]   ` <CAH9JG2XSpFJeUvv7cw-JWadmi=X0-4EsN5FFKuDkwo=-mmzHSQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-02-05  0:03     ` Cong Ding
2013-02-05  0:05     ` [PATCH v2] " Cong Ding
     [not found]       ` <20130205000517.GB9969-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-05  1:14         ` Haojian Zhuang
     [not found]           ` <CAN1soZwM6qNTJn3vvMdc6TR1eJHc=K+_c0WuWOBBuFYMWB_oCA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-02-05 10:25             ` Cong Ding
     [not found]               ` <20130205102540.GC9969-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-05 11:27                 ` Haojian Zhuang
2013-02-14 11:28                   ` [PATCH v3] " Cong Ding
     [not found]                     ` <20130214112818.GA18774-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-14 16:10                       ` Haojian Zhuang
2013-03-21 10:54                     ` Wolfram Sang [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=20130321105429.GE19297@the-dreams.de \
    --to=wsa@the-dreams.de \
    --cc=akpm@linux-foundation.org \
    --cc=dinggnu@gmail.com \
    --cc=haojian.zhuang@gmail.com \
    --cc=haojian.zhuang@marvell.com \
    --cc=k.lewandowsk@samsung.com \
    --cc=kmpark@infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=w.sang@pengutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).