Commit bbc2ceeb authored by Guenter Roeck's avatar Guenter Roeck Committed by Dmitry Torokhov

Input: synaptics-rmi4 - fix error handling in SPI transport driver

Instantiating the rmi4 SPI transport driver without an interrupt assigned
caused the driver to fail to load, but it does not clean up its transport
device registration. Result may be a crash at a later time, for example
when rebooting the system.

Fixes: 8d99758d ("Input: synaptics-rmi4 - add SPI transport driver")
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 574a62c9
...@@ -396,6 +396,13 @@ static inline int rmi_spi_of_probe(struct spi_device *spi, ...@@ -396,6 +396,13 @@ static inline int rmi_spi_of_probe(struct spi_device *spi,
} }
#endif #endif
static void rmi_spi_unregister_transport(void *data)
{
struct rmi_spi_xport *rmi_spi = data;
rmi_unregister_transport_device(&rmi_spi->xport);
}
static int rmi_spi_probe(struct spi_device *spi) static int rmi_spi_probe(struct spi_device *spi)
{ {
struct rmi_spi_xport *rmi_spi; struct rmi_spi_xport *rmi_spi;
...@@ -464,6 +471,11 @@ static int rmi_spi_probe(struct spi_device *spi) ...@@ -464,6 +471,11 @@ static int rmi_spi_probe(struct spi_device *spi)
dev_err(&spi->dev, "failed to register transport.\n"); dev_err(&spi->dev, "failed to register transport.\n");
return retval; return retval;
} }
retval = devm_add_action_or_reset(&spi->dev,
rmi_spi_unregister_transport,
rmi_spi);
if (retval)
return retval;
retval = rmi_spi_init_irq(spi); retval = rmi_spi_init_irq(spi);
if (retval < 0) if (retval < 0)
...@@ -473,15 +485,6 @@ static int rmi_spi_probe(struct spi_device *spi) ...@@ -473,15 +485,6 @@ static int rmi_spi_probe(struct spi_device *spi)
return 0; return 0;
} }
static int rmi_spi_remove(struct spi_device *spi)
{
struct rmi_spi_xport *rmi_spi = spi_get_drvdata(spi);
rmi_unregister_transport_device(&rmi_spi->xport);
return 0;
}
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static int rmi_spi_suspend(struct device *dev) static int rmi_spi_suspend(struct device *dev)
{ {
...@@ -577,7 +580,6 @@ static struct spi_driver rmi_spi_driver = { ...@@ -577,7 +580,6 @@ static struct spi_driver rmi_spi_driver = {
}, },
.id_table = rmi_id, .id_table = rmi_id,
.probe = rmi_spi_probe, .probe = rmi_spi_probe,
.remove = rmi_spi_remove,
}; };
module_spi_driver(rmi_spi_driver); module_spi_driver(rmi_spi_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment