[PATCH 17/21] leds: aat1290: Avoid leaking devres pinctrl handles on strobe source changes

From: Lee Jones

Date: Wed Oct 21 2026 - 08:49:29 EST


aat1290_led_external_strobe_set() is a runtime V4L2 control callback
that calls devm_pinctrl_get_select() every time the strobe source is
switched. Because devm_pinctrl_get() allocates a new devres entry and
takes an additional pinctrl reference on each call, repeated updates to
V4L2_CID_FLASH_STROBE_SOURCE leak memory and pinctrl references for the
lifetime of the device.

Use pinctrl_get_select() followed by pinctrl_put() instead, as the
device's underlying pinctrl instance is already held across the device
lifetime.

Fixes: ac69b9038f82 ("leds: aat1290: add support for V4L2 Flash sub-device")
Closes: https://sashiko.dev/#/bug/linux-e1e22682-0cb6-4dcc-9a7f-01993691f7b0
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/leds/flash/leds-aat1290.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/flash/leds-aat1290.c b/drivers/leds/flash/leds-aat1290.c
index 223bbba9114f..fc7904966183 100644
--- a/drivers/leds/flash/leds-aat1290.c
+++ b/drivers/leds/flash/leds-aat1290.c
@@ -413,13 +413,15 @@ static int aat1290_led_external_strobe_set(struct v4l2_flash *v4l2_flash,
led->movie_mode = false;
led_cdev->brightness = 0;

- pinctrl = devm_pinctrl_get_select(&led->pdev->dev,
- enable ? "isp" : "host");
+ pinctrl = pinctrl_get_select(&led->pdev->dev,
+ enable ? "isp" : "host");
if (IS_ERR(pinctrl)) {
dev_warn(&led->pdev->dev, "Unable to switch strobe source.\n");
return PTR_ERR(pinctrl);
}

+ pinctrl_put(pinctrl);
+
return 0;
}

--
2.56.0.218.g1ec904b173-goog