Linux LED subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Cong Nguyen" <congnt264@gmail.com>
Cc: linux-leds@vger.kernel.org, lee@kernel.org
Subject: Re: [PATCH 1/2] leds: flash: qcom-flash: fix the v4l2 flash release loops
Date: Tue, 24 Nov 2026 10:05:25 +0000	[thread overview]
Message-ID: <sashiko-outbox-230911@kernel.org> (raw)
In-Reply-To: <20261124095408.3842986-1-congnt264@gmail.com>

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] leds: qcom-flash: use-after-free in qcom_flash_led_probe()
  [1]
--

commit 01b91774110dfcae9bec7d39022e0b10aec8e56b
Author: Cong Nguyen <congnt264@gmail.com>

leds: flash: qcom-flash: fix the v4l2 flash release loops

This commit fixes the v4l2_flash_release() loops in the probe error path
and remove callback to release indices from leds_count - 1 down to 0.

> diff --git a/drivers/leds/flash/leds-qcom-flash.c b/drivers/leds/flash/leds-qcom-flash.c
> index 4e62a210cf98d..1003ba060b423 100644
> --- a/drivers/leds/flash/leds-qcom-flash.c
> +++ b/drivers/leds/flash/leds-qcom-flash.c
> @@ -953,8 +953,8 @@ static int qcom_flash_led_probe(struct platform_device *pdev)
>  
>  	return regmap_field_write(flash_data->r_fields[REG_TORCH_CLAMP], flash_data->torch_clamp);
>  release:
> -	while (flash_data->v4l2_flash[flash_data->leds_count] && flash_data->leds_count)
> -		v4l2_flash_release(flash_data->v4l2_flash[flash_data->leds_count--]);
> +	while (flash_data->leds_count)
> +		v4l2_flash_release(flash_data->v4l2_flash[--flash_data->leds_count]);
>  	return rc;
>  }

[Severity: Critical]
This problem wasn't introduced by this patch, but does returning directly
when regmap_field_write() fails skip the release label and leave
flash_data->v4l2_flash[] subdevices registered [1]?  When probe
returns an error, devres frees the backing device-managed memory while V4L2
still holds pointers to the subdevices, leading to a use-after-free.

[1] https://sashiko.dev/#/bug/linux-e48f7fbe-dd94-4b3f-aff8-e1dc279dec37

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261124095408.3842986-1-congnt264@gmail.com?part=1

  parent reply	other threads:[~2026-11-24 10:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  9:54 [PATCH 1/2] leds: flash: qcom-flash: fix the v4l2 flash release loops Cong Nguyen
2026-11-24  9:54 ` [PATCH 2/2] leds: flash: qcom-flash: release v4l2 flash devices on torch clamp failure Cong Nguyen
2026-11-24 10:05 ` sashiko-bot [this message]
2026-11-24 10:05 ` [PATCH 1/2] leds: flash: qcom-flash: fix the v4l2 flash release loops sashiko-bot

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-230911@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=congnt264@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