All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Thorsten Blum" <blum@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 3/3] backlight: aat2870: Initialize properties before device registration
Date: Thu, 19 Nov 2026 23:17:51 +0000	[thread overview]
Message-ID: <sashiko-outbox-224178@kernel.org> (raw)
In-Reply-To: <20261119230733.790573-6-blum@kernel.org>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] backlight: aat2870_bl: NULL pointer dereference in
  aat2870_bl_update_status() [1]
--

commit d325449f615b625e1f4a4a3e7a3f53db9a33c1e2
Author: Thorsten Blum <blum@kernel.org>

backlight: aat2870: Initialize properties before device registration

This commit initializes the backlight properties before calling
devm_backlight_device_register() so that max_brightness and initial
brightness are set before the sysfs attributes are exposed to userspace.

> diff --git a/drivers/video/backlight/aat2870_bl.c b/drivers/video/backlight/aat2870_bl.c
> index 5af36d3784f11..fa854827e5580 100644
> --- a/drivers/video/backlight/aat2870_bl.c
> +++ b/drivers/video/backlight/aat2870_bl.c
[ ... ]
> @@ -120,9 +124,10 @@ static int aat2870_bl_probe(struct platform_device *pdev)
>  		goto out;
>  	}
>  
> -	memset(&props, 0, sizeof(struct backlight_properties));
> +	if (pdata->max_brightness > 0)
> +		props.max_brightness = pdata->max_brightness;
> +	props.brightness = props.max_brightness;
>  
> -	props.type = BACKLIGHT_RAW;
>  	bd = devm_backlight_device_register(&pdev->dev, "aat2870-backlight",
>  					&pdev->dev, aat2870_bl, &aat2870_bl_ops,
>  					&props);

[Severity: Critical]
This problem wasn't introduced by this patch, but can registering the
backlight device before initializing aat2870_bl->pdev cause a NULL pointer
dereference in aat2870_bl_update_status() [1]?

devm_backlight_device_register() exposes the sysfs interface before
aat2870_bl_probe() populates aat2870_bl->pdev (and aat2870_bl->bd,
channels, and max_current):

drivers/video/backlight/aat2870_bl.c:aat2870_bl_update_status() {
	struct aat2870_bl_driver_data *aat2870_bl = bl_get_data(bd);
	struct aat2870_data *aat2870 =
			dev_get_drvdata(aat2870_bl->pdev->dev.parent);
    ...
}

If userspace writes to a sysfs attribute such as brightness right after
registration, the backlight core invokes aat2870_bl_update_status() while
aat2870_bl->pdev is still NULL:

CPU0                                CPU1
aat2870_bl_probe()
  devm_backlight_device_register()
                                    brightness_store()
                                      ...
                                        aat2870_bl_update_status()
                                          aat2870_bl->pdev->dev.parent
                                            <-- NULL pointer dereference
  aat2870_bl->pdev = pdev;

Initializing the driver data fields in aat2870_bl before calling
devm_backlight_device_register() would avoid this race.

[1] https://sashiko.dev/#/bug/linux-9a61532b-5d7a-467d-b3d1-d6420978c8f3

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119230733.790573-4-blum@kernel.org?part=3

      reply	other threads:[~2026-11-19 23:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 23:07 [PATCH 1/3] backlight: ktd253: Initialize properties before device registration Thorsten Blum
2026-11-19 23:07 ` [PATCH 2/3] backlight: ktd2801: " Thorsten Blum
2026-11-19 23:07 ` [PATCH 3/3] backlight: aat2870: " Thorsten Blum
2026-11-19 23:17   ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-224178@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=blum@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.