Skip to content

Commit

Permalink
Input: ads7846 - return error on regulator_get() failure
Browse files Browse the repository at this point in the history
In probe(), if regulator_get() failed, an error code was not being
returned causing the driver to be successfully bound, even though
probe failed.  This in turn caused the suspend, resume and remove
methods to be registered and accessed via the SPI core.  Since these
functions all access private driver data using pointers that had been
freed during the failed probe, this would lead to unpredictable
behavior.

This patch ensures that probe() returns an error code in this failure
case so the driver is not bound.

Found using lockdep and noticing the lock used in the suspend/resum
path pointed to a bogus lock due to the freed memory.

Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
  • Loading branch information
Kevin Hilman authored and Dmitry Torokhov committed May 27, 2010
1 parent f2126a9 commit 067fb2f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/input/touchscreen/ads7846.c
Original file line number Diff line number Diff line change
Expand Up @@ -1163,8 +1163,8 @@ static int __devinit ads7846_probe(struct spi_device *spi)

ts->reg = regulator_get(&spi->dev, "vcc");
if (IS_ERR(ts->reg)) {
dev_err(&spi->dev, "unable to get regulator: %ld\n",
PTR_ERR(ts->reg));
err = PTR_ERR(ts->reg);
dev_err(&spi->dev, "unable to get regulator: %ld\n", err);
goto err_free_gpio;
}

Expand Down

0 comments on commit 067fb2f

Please sign in to comment.