From: Adam Ford <aford173@gmail.com>
To: linux-input@vger.kernel.org
Cc: dmitry.torokhov@gmail.com, linux-kernel@vger.kernel.org,
Adam Ford <aford173@gmail.com>
Subject: [PATCH] Input: ili210x: Fix potential memory leaks
Date: Tue, 4 Aug 2020 13:30:07 -0500 [thread overview]
Message-ID: <20200804183007.117125-1-aford173@gmail.com> (raw)
This driver requests, memory twice and requests a threaded irq, but
it doesn't free any of them if something fails.
This patch attempts to identify areas where a return was issued
without freeing allocated memory or IRQ's.
Signed-off-by: Adam Ford <aford173@gmail.com>
diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
index 199cf3daec10..967329fbdde3 100644
--- a/drivers/input/touchscreen/ili210x.c
+++ b/drivers/input/touchscreen/ili210x.c
@@ -421,7 +421,7 @@ static int ili210x_i2c_probe(struct i2c_client *client,
input = devm_input_allocate_device(dev);
if (!input)
- return -ENOMEM;
+ goto free_priv;
priv->client = client;
priv->input = input;
@@ -443,7 +443,7 @@ static int ili210x_i2c_probe(struct i2c_client *client,
INPUT_MT_DIRECT);
if (error) {
dev_err(dev, "Unable to set up slots, err: %d\n", error);
- return error;
+ goto free_input;
}
error = devm_request_threaded_irq(dev, client->irq, NULL, ili210x_irq,
@@ -451,27 +451,36 @@ static int ili210x_i2c_probe(struct i2c_client *client,
if (error) {
dev_err(dev, "Unable to request touchscreen IRQ, err: %d\n",
error);
- return error;
+ goto free_input;
}
error = devm_add_action_or_reset(dev, ili210x_stop, priv);
if (error)
- return error;
+ goto free_irq;
error = devm_device_add_group(dev, &ili210x_attr_group);
if (error) {
dev_err(dev, "Unable to create sysfs attributes, err: %d\n",
error);
- return error;
+ goto free_irq;
}
error = input_register_device(priv->input);
if (error) {
dev_err(dev, "Cannot register input device, err: %d\n", error);
- return error;
+ goto free_irq;
}
return 0;
+
+free_irq:
+ free_irq(client->irq, client);
+free_input:
+ input_free_device(input);
+free_priv:
+ kfree(priv);
+
+ return error;
}
static const struct i2c_device_id ili210x_i2c_id[] = {
--
2.25.1
next reply other threads:[~2020-08-04 18:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-04 18:30 Adam Ford [this message]
2020-08-05 7:50 ` [PATCH] Input: ili210x: Fix potential memory leaks Marco Felsch
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=20200804183007.117125-1-aford173@gmail.com \
--to=aford173@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.