Re: [PATCH v3 1/4] backlight: qcom-wled: Fix NULL pointer dereference in PM callbacks
From: Konrad Dybcio
Date: Mon Sep 21 2026 - 05:35:15 EST
On 9/14/26 8:14 PM, David Heidelberg via B4 Relay wrote:
> From: David Heidelberg <david@xxxxxxx>
>
> wled_probe() doesn't set the driver data for the platform device.
> As a result, dev_get_drvdata() in wled_remove() will return NULL,
> leading to a NULL pointer dereference afterward.
>
> Set the platform device driver data in wled_probe().
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: feeab87b3072 ("backlight: qcom-wled: Add support for short circuit handling")
> Signed-off-by: David Heidelberg <david@xxxxxxx>
> ---
> drivers/video/backlight/qcom-wled.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c
> index 650dd95f06ef5..a76158a298335 100644
> --- a/drivers/video/backlight/qcom-wled.c
> +++ b/drivers/video/backlight/qcom-wled.c
> @@ -1747,16 +1747,17 @@ static int wled_probe(struct platform_device *pdev)
>
> memset(&props, 0, sizeof(struct backlight_properties));
> props.type = BACKLIGHT_RAW;
> props.brightness = val;
> props.max_brightness = wled->max_brightness;
> bl = devm_backlight_device_register(&pdev->dev, wled->name,
> &pdev->dev, wled,
> &wled_ops, &props);
> + platform_set_drvdata(pdev, bl);
This does make the pointer non-null, but it stores the wrong object
Konrad
> return PTR_ERR_OR_ZERO(bl);
> };
>
> static void wled_remove(struct platform_device *pdev)
> {
> struct wled *wled = platform_get_drvdata(pdev);
>
> mutex_destroy(&wled->lock);
>