backlight: adp5520: fix error handling in adp5520_bl_probe()
diff mbox series

Message ID 1468016392-6061-1-git-send-email-khoroshilov@ispras.ru
State New, archived
Headers show
Series
  • backlight: adp5520: fix error handling in adp5520_bl_probe()
Related show

Commit Message

Alexey Khoroshilov July 8, 2016, 10:19 p.m. UTC
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 <khoroshilov@ispras.ru>
---
 drivers/video/backlight/adp5520_bl.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Hennerich, Michael July 11, 2016, 7:25 a.m. UTC | #1
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 <khoroshilov@ispras.ru>

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)
>
Lee Jones Aug. 5, 2016, 1:29 p.m. UTC | #2
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 <khoroshilov@ispras.ru>
> ---
>  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)

Patch
diff mbox series

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)