From: Dan Carpenter <error27@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@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: [patch -next] input: adxl34x: fix leak and use after free
Date: Thu, 22 Jul 2010 10:55:52 +0200 [thread overview]
Message-ID: <20100722085552.GW17585@bicker> (raw)
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>
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);
next reply other threads:[~2010-07-22 8:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-22 8:55 Dan Carpenter [this message]
2010-07-23 6:44 ` [patch -next] input: adxl34x: fix leak and use after free Dmitry Torokhov
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=20100722085552.GW17585@bicker \
--to=error27@gmail.com \
--cc=chrisv@cyberswitching.com \
--cc=dmitry.torokhov@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).