l4f00242t03: fix error handling in l4f00242t03_probe
Subsystems (2)
PATCH 1/1 l4f00242t03: fix error handling in l4f00242t03_probe
This patch includes below fixes for properly error handling:
1. In the case of kzalloc failure, simple return -ENOMEM instead of goto err. ( priv is NULL in this case )
2. In the case of gpio_request fail for reset_gpio and data_enable_gpio, properly release resources by goto err and err2 respectively.
--- drivers/video/backlight/l4f00242t03.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
(quoted diff) +0 -0
b/drivers/video/backlight/l4f00242t03.c
index bcdb12c..a4632db 100644
drivers/video/backlight/l4f00242t03.c +0 -0
@@ -125,8 +125,7 @@ static int __devinit l4f00242t03_probe(struct
spi_device *spi)
if (priv == NULL) {
dev_err(&spi->dev, "No memory for this device.\n");
- ret = -ENOMEM;
- goto err;
+ return -ENOMEM;
}
dev_set_drvdata(&spi->dev, priv);
@@ -139,7 +138,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
if (ret) {
dev_err(&spi->dev,
"Unable to get the lcd l4f00242t03 reset gpio.\n");
- return ret;
+ goto err;
}
ret = gpio_direction_output(pdata->reset_gpio, 1);
@@ -151,7 +150,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
if (ret) {
dev_err(&spi->dev,
"Unable to get the lcd l4f00242t03 data en gpio.\n");
- return ret;
+ goto err2;
}
ret = gpio_direction_output(pdata->data_enable_gpio, 0);
Signature · 1 line
1.5.4.3
Quoted 7 lines · Axel Lin
This patch includes below fixes for properly error handling:
1. In the case of kzalloc failure, simple return-ENOMEMinstead of goto err. ( priv is NULL in this case )
2. In the case ofgpio_requestfail forreset_gpioanddata_enable_gpio, properly release resources by goto err and err2 respectively.Signed-off-by Axel Lin <[email protected]>
Tank you for these fixes!
Alberto!
Quoted 40 lines
--- drivers/video/backlight/l4f00242t03.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)drivers/video/backlight/l4f00242t03.c +1
-2@@ -125,8 +125,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)if (priv ==NULL ) {dev_err (&spi->dev,"No memory for this device.\n" ); - ret = -ENOMEM ; - goto err; +return -ENOMEM ; }drivers/video/backlight/l4f00242t03.c +1
-1dev_set_drvdata (&spi->dev, priv);@@ -139,7 +138,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) if (ret) {dev_err (&spi->dev,"Unable to get the lcd l4f00242t03 reset gpio.\n" ); -return ret; + goto err; }drivers/video/backlight/l4f00242t03.c +1
-1ret =gpio_direction_output (pdata->reset_gpio,1 );@@ -151,7 +150,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi) if (ret) {dev_err (&spi->dev,"Unable to get the lcd l4f00242t03 data en gpio.\n" ); -return ret; + goto err2; }ret =
gpio_direction_output(pdata->data_enable_gpio, 0);