linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Dan Carpenter <error27@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>,
	Michael Hennerich <michael.hennerich@analog.com>,
	Chris Verges <chrisv@cyberswitching.com>,
	Luotao Fu <l.fu@pengutronix.de>,
	linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch -next] input: adxl34x: fix leak and use after free
Date: Thu, 22 Jul 2010 23:44:35 -0700	[thread overview]
Message-ID: <20100723064435.GC20532@core.coreip.homeip.net> (raw)
In-Reply-To: <20100722085552.GW17585@bicker>

On Thu, Jul 22, 2010 at 10:55:52AM +0200, Dan Carpenter wrote:
> These are a couple smatch issues.  In the original code, if only one of
> the allocation fails we leak the other variable so we should goto
> out_free_mem.
> 
> Also there was a use after free if debugging was enabled and so I moved
> the kfree() down a line.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 

Applied, thanks Dan.

> diff --git a/drivers/input/misc/adxl34x.c b/drivers/input/misc/adxl34x.c
> index bb9c10f..e925d12 100644
> --- a/drivers/input/misc/adxl34x.c
> +++ b/drivers/input/misc/adxl34x.c
> @@ -709,7 +709,7 @@ struct adxl34x *adxl34x_probe(struct device *dev, int irq,
>  	input_dev = input_allocate_device();
>  	if (!ac || !input_dev) {
>  		err = -ENOMEM;
> -		goto err_out;
> +		goto err_free_mem;
>  	}
>  
>  	ac->fifo_delay = fifo_delay_default;
> @@ -904,9 +904,9 @@ int adxl34x_remove(struct adxl34x *ac)
>  	sysfs_remove_group(&ac->dev->kobj, &adxl34x_attr_group);
>  	free_irq(ac->irq, ac);
>  	input_unregister_device(ac->input);
> +	dev_dbg(ac->dev, "unregistered accelerometer\n");
>  	kfree(ac);
>  
> -	dev_dbg(ac->dev, "unregistered accelerometer\n");
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(adxl34x_remove);

-- 
Dmitry

      reply	other threads:[~2010-07-23  6:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-22  8:55 [patch -next] input: adxl34x: fix leak and use after free Dan Carpenter
2010-07-23  6:44 ` Dmitry Torokhov [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=20100723064435.GC20532@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=chrisv@cyberswitching.com \
    --cc=error27@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=l.fu@pengutronix.de \
    --cc=linux-input@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    --cc=vapier@gentoo.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;
as well as URLs for NNTP newsgroup(s).