From: sashiko-bot@kernel.org
To: "Danish Khateeb" <danishkhateeb03@gmail.com>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH v2] leds: tca6507: Fix use-after-free on unbind
Date: Thu, 15 Oct 2026 14:48:49 +0000 [thread overview]
Message-ID: <sashiko-outbox-172992@kernel.org> (raw)
In-Reply-To: <20261015144033.56519-1-danishkhateeb03@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] leds: tca6507: devres cancels work before LED off commands are sent
--
commit 26c3a76d710837c5d81cb4e74292b31880a4a3d5
Author: Danish Khateeb <danishkhateeb03@gmail.com>
leds: tca6507: Fix use-after-free on unbind
Set up the work with devm_work_autocancel() before the LEDs are registered,
so that devres cancels it after they are gone, and drop tca6507_remove().
This resolves a previous use-after-free.
> diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
> index 9afe2722986cf..0f987e551f03d 100644
> --- a/drivers/leds/leds-tca6507.c
> +++ b/drivers/leds/leds-tca6507.c
[ ... ]
> @@ -735,9 +736,11 @@ static int tca6507_probe(struct i2c_client *client)
> return -ENOMEM;
>
> tca->client = client;
> - INIT_WORK(&tca->work, tca6507_work);
> spin_lock_init(&tca->lock);
> - i2c_set_clientdata(client, tca);
> +
> + err = devm_work_autocancel(dev, &tca->work, tca6507_work);
> + if (err)
> + return err;
[Severity: Medium]
Since this devres action is registered before the LEDs are registered later
in tca6507_probe(), doesn't it run after them during unbind?
When the driver is unbound, devres will first unregister the LEDs, which
sets their brightness to LED_OFF. The driver's brightness_set callback
will queue an I2C transaction via schedule_work(&tca->work).
Immediately after, devres invokes the devm_work_autocancel action, which
calls cancel_work_sync(&tca->work). Since the work is still pending, it gets
cancelled before it can run, meaning the I2C write to turn off the LEDs
never occurs.
Although this resolves the previous use-after-free, does it prevent the
LEDs from correctly turning off on teardown, causing the hardware LEDs to
physically stay on after driver unbind?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261015144033.56519-1-danishkhateeb03@gmail.com?part=1
prev parent reply other threads:[~2026-10-15 14:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 14:40 [PATCH v2] leds: tca6507: Fix use-after-free on unbind Danish Khateeb
2026-10-15 14:48 ` 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-172992@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=danishkhateeb03@gmail.com \
--cc=lee@kernel.org \
--cc=linux-leds@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox