All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Guenter Roeck <linux@roeck-us.net>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Andrew Duggan <aduggan@synaptics.com>
Subject: [PATCH] Input: synaptics-rmi4 - Fix error handling in I2C transport driver
Date: Wed, 28 Sep 2016 17:37:06 -0700	[thread overview]
Message-ID: <1475109426-23644-1-git-send-email-linux@roeck-us.net> (raw)

Instantiating the rmi4 I2C transport driver without interrupts assigned
(for example using manual i2c instantiation from the command line)
caused the driver to fail to load, but it does not clean up its
regulator or transport device registrations. Result is a crash at a later
time, for example when rebooting the system.

Fixes: 946c8432aab0 ("Input: synaptics-rmi4 - support regulator supplies")
Fixes: fdf51604f104 ("Input: synaptics-rmi4 - add I2C transport driver")
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Andrew Duggan <aduggan@synaptics.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/input/rmi4/rmi_i2c.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
index 6f2e0e4f0296..d57b227ccd25 100644
--- a/drivers/input/rmi4/rmi_i2c.c
+++ b/drivers/input/rmi4/rmi_i2c.c
@@ -285,23 +285,30 @@ static int rmi_i2c_probe(struct i2c_client *client,
 	retval = rmi_set_page(rmi_i2c, 0);
 	if (retval) {
 		dev_err(&client->dev, "Failed to set page select to 0.\n");
-		return retval;
+		goto error_disable;
 	}
 
 	retval = rmi_register_transport_device(&rmi_i2c->xport);
 	if (retval) {
 		dev_err(&client->dev, "Failed to register transport driver at 0x%.2X.\n",
 			client->addr);
-		return retval;
+		goto error_disable;
 	}
 
 	retval = rmi_i2c_init_irq(client);
 	if (retval < 0)
-		return retval;
+		goto error_unregister;
 
 	dev_info(&client->dev, "registered rmi i2c driver at %#04x.\n",
 			client->addr);
 	return 0;
+
+error_unregister:
+	rmi_unregister_transport_device(&rmi_i2c->xport);
+error_disable:
+	regulator_bulk_disable(ARRAY_SIZE(rmi_i2c->supplies),
+			       rmi_i2c->supplies);
+	return retval;
 }
 
 static int rmi_i2c_remove(struct i2c_client *client)
-- 
2.5.0

             reply	other threads:[~2016-09-29  0:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-29  0:37 Guenter Roeck [this message]
2016-09-29 17:55 ` [PATCH] Input: synaptics-rmi4 - Fix error handling in I2C transport driver Bjorn Andersson
2016-09-30 22:54   ` Dmitry Torokhov
2016-09-30 23:02     ` Dmitry Torokhov
2016-10-01  3:44       ` Guenter Roeck
2016-10-01 17:27         ` Andrew Duggan
2016-10-01 17:45           ` Guenter Roeck
2016-10-01 17:51             ` Andrew Duggan
2016-10-01 19:04           ` Dmitry Torokhov
2016-10-01 20:46             ` Guenter Roeck
2016-10-01  3:03     ` Guenter Roeck

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=1475109426-23644-1-git-send-email-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=aduggan@synaptics.com \
    --cc=bjorn.andersson@linaro.org \
    --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.