# \[PATCH\] backlight: adp5520: fix error handling in adp5520\_bl\_probe()

- Subsystems: FRAMEBUFFER LAYER, ADP5520 BACKLIGHT DRIVER WITH IO EXPANDER (ADP5520/ADP5501), BACKLIGHT CLASS/SUBSYSTEM, THE REST
- Maintainers: Helge Deller, Michael Hennerich, Lee Jones, Daniel Thompson, Jingoo Han, Linus Torvalds
- List: linux-fbdev
- 3 messages, 3 authors
- Page: https://ratatoskr.run/linux-fbdev/2016/07/4791366/t

## \[PATCH\] backlight: adp5520: fix error handling in adp5520\_bl\_probe()

- From: Alexey Khoroshilov \<hidden\>
- Date: 2016-07-08 22:20:08 
- Message: https://ratatoskr.run/linux-fbdev/2016/07/4791366.md

```text
If adp5520_bl_setup() fails, sysfs group left unremoved.

By the way, fix overcomplicated assignement of error code.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <redacted>
---
 drivers/video/backlight/adp5520_bl.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c
index dd88ba1d71ce..35373e2065b2 100644
--- a/drivers/video/backlight/adp5520_bl.c
+++ b/drivers/video/backlight/adp5520_bl.c
@@ -332,10 +332,18 @@ static int adp5520_bl_probe(struct platform_device *pdev)
 	}
 
 	platform_set_drvdata(pdev, bl);
-	ret |= adp5520_bl_setup(bl);
+	ret = adp5520_bl_setup(bl);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to setup\n");
+		if (data->pdata->en_ambl_sens)
+			sysfs_remove_group(&bl->dev.kobj,
+					&adp5520_bl_attr_group);
+		return ret;
+	}
+
 	backlight_update_status(bl);
 
-	return ret;
+	return 0;
 }
 
 static int adp5520_bl_remove(struct platform_device *pdev)
-- 
1.9.1

```

## Re: \[PATCH\] backlight: adp5520: fix error handling in adp5520\_bl\_probe()

- From: Michael Hennerich \<michael.hennerich@analog.com\>
- Date: 2016-07-11 11:00:44 
- Message: https://ratatoskr.run/linux-fbdev/2016/07/4792034.md

```text
On 09.07.2016 00:19, Alexey Khoroshilov wrote:
> If adp5520_bl_setup() fails, sysfs group left unremoved.
>
> By the way, fix overcomplicated assignement of error code.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <redacted>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>   drivers/video/backlight/adp5520_bl.c | 12 ++++++++++--
>   1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c
> index dd88ba1d71ce..35373e2065b2 100644
> --- a/drivers/video/backlight/adp5520_bl.c
> +++ b/drivers/video/backlight/adp5520_bl.c
> @@ -332,10 +332,18 @@ static int adp5520_bl_probe(struct platform_device *pdev)
>   	}
>
>   	platform_set_drvdata(pdev, bl);
> -	ret |= adp5520_bl_setup(bl);
> +	ret = adp5520_bl_setup(bl);
> +	if (ret) {
> +		dev_err(&pdev->dev, "failed to setup\n");
> +		if (data->pdata->en_ambl_sens)
> +			sysfs_remove_group(&bl->dev.kobj,
> +					&adp5520_bl_attr_group);
> +		return ret;
> +	}
> +
>   	backlight_update_status(bl);
>
> -	return ret;
> +	return 0;
>   }
>
>   static int adp5520_bl_remove(struct platform_device *pdev)
>


-- 
Greetings,
Michael

--
Analog Devices GmbH      Otl-Aicher Strasse 60-64      80807 München
Sitz der Gesellschaft München, Registergericht München HRB 40368,
Geschäftsführer: Peter Kolberg, Ali Raza Husain, Eileen Wynne
```

## Re: \[PATCH\] backlight: adp5520: fix error handling in adp5520\_bl\_probe()

- From: Lee Jones \<hidden\>
- Date: 2016-08-05 13:28:23 
- Message: https://ratatoskr.run/linux-fbdev/2016/08/4808784.md

```text
On Sat, 09 Jul 2016, Alexey Khoroshilov wrote:

> If adp5520_bl_setup() fails, sysfs group left unremoved.
> 
> By the way, fix overcomplicated assignement of error code.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov <redacted>
> ---
>  drivers/video/backlight/adp5520_bl.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)

Applied, thanks.

> diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c
> index dd88ba1d71ce..35373e2065b2 100644
> --- a/drivers/video/backlight/adp5520_bl.c
> +++ b/drivers/video/backlight/adp5520_bl.c
> @@ -332,10 +332,18 @@ static int adp5520_bl_probe(struct platform_device *pdev)
>  	}
>  
>  	platform_set_drvdata(pdev, bl);
> -	ret |= adp5520_bl_setup(bl);
> +	ret = adp5520_bl_setup(bl);
> +	if (ret) {
> +		dev_err(&pdev->dev, "failed to setup\n");
> +		if (data->pdata->en_ambl_sens)
> +			sysfs_remove_group(&bl->dev.kobj,
> +					&adp5520_bl_attr_group);
> +		return ret;
> +	}
> +
>  	backlight_update_status(bl);
>  
> -	return ret;
> +	return 0;
>  }
>  
>  static int adp5520_bl_remove(struct platform_device *pdev)

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org â”‚ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
```
