diff mbox

touchscreen: ads7846: please don't touch free'd memory

Message ID 87mxvnlpxv.fsf@deeprootsystems.com (mailing list archive)
State Superseded
Delegated to: Kevin Hilman
Headers show

Commit Message

Kevin Hilman May 25, 2010, 7:52 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index b3a1f92..42d4d26 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -175,6 +175,8 @@  static void spi_drv_shutdown(struct device *dev)
  */
 int spi_register_driver(struct spi_driver *sdrv)
 {
+	int ret;
+
 	sdrv->driver.bus = &spi_bus_type;
 	if (sdrv->probe)
 		sdrv->driver.probe = spi_drv_probe;
@@ -182,7 +184,12 @@  int spi_register_driver(struct spi_driver *sdrv)
 		sdrv->driver.remove = spi_drv_remove;
 	if (sdrv->shutdown)
 		sdrv->driver.shutdown = spi_drv_shutdown;
-	return driver_register(&sdrv->driver);
+
+	ret = driver_register(&sdrv->driver);
+	if (!ret)
+		driver_unregister(&sdrv->driver);
+
+	return ret;
 }
 EXPORT_SYMBOL_GPL(spi_register_driver);