From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796365587; b=X5/uYasZf229EZaP84sMxBdH/SnTZDVNAa2/CzECvV3rQdr+QL2K+Ct01wefi+KdaBT5 s5HiMakQkPHN7JRsex8eajy90DGumb2B/ljENbHh5UBeuJELxnDCZiVxiMhoTaSKjARFS T4dvNl1aVhNfjJHjxxw10gOUfrCTCBAfGVlqs1IHhaU32ro9xgNuAhzjGOKXcHuybVC5+ OC43bERjqam+eUadoOOWFPQsBxIsqn+v9QnDNhya5J1NQOLVEpUAf8tStnt5IzlhDMAV0 5MBbRJPtOgtK7nleMRJPcVFWcKgsoEFVJEchruAgpNEMITobenoYVU+I1iNekjF2zTQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796365587; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=9DQyGXgzHdfG0IvNkhljwu/0ikkGAow8tpRdqJb7xk8=; b=mL4ZDHiYNhQzhfoy2cbzaRDGiuiA4njnu+0RLKxyHmLcBWRy1Osfm1T/U1UuemFkWGu6 Q0ciQ5FETGfro8NSWZo/TkfJ1sG180r1n0itBb3b8BpnAHQtZygKonsrg+Brux65QdjUm MItw1cn7Al35Bk9XTRbF2Yq3Oeg0PT9DrzdCidup56NN2viFeulZYHNgYAiKl+S69xa83 nXvuVNgSYqaOmfHKo3E6zI9PSBvdo4c2Cy53tisY/Uu5AbOYpx5XkpmvHLLytuA17WK/8 tnhJgG0heW/VDpigngFhk+07HInESO0v0yxtcw/svICXyId+DSFsb33cJbcuBj3NOvA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=h7qDwEno; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 206A6606A322 for ; Fri, 4 Dec 2026 06:26:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=h7qDwEno Received: by smtp.kernel.org (Postfix) with ESMTPSA id 680AE1F0092C; Fri, 4 Dec 2026 06:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796365586; bh=9DQyGXgzHdfG0IvNkhljwu/0ikkGAow8tpRdqJb7xk8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=h7qDwEnoQcjS+GZpqpj7/IYXShBXl0TLVQ9lGJU2XGfjfziv4jzPiOVGpWEEyo6bL Lcxr83bXHMvFknQfUYdwWeUBhZ5kZgmlKS4l8RWhKDCFR+6IUDVk9LVOQIhKfILXdi J7DpqejkB9fFEZmFygBQXSAJHalWfr6ROIP0bV/qAtM4gOZX718bx8fs8+CMAdKtrf P+424QNGne9A0pcGW842SGTiYNpTk/survaunMjX8qpdX7R+R8aKpZp11u/2SuPiJ0 CW4cYpMhF6dCRB4cMSuOUZbK/4gzBBA2EdqKFWBkX4C19aA0OVXby20H1CJIzmZg6a RR/DF3KxFYZPQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 1/2] leds: lm3533: Clean up probe and use managed helpers Reply-To: sashiko-reviews@lists.linux.dev To: "Svyatoslav Ryhel" Cc: linux-leds@vger.kernel.org, lee@kernel.org In-Reply-To: <20261204061642.40608-2-clamor95@gmail.com> References: <20261204061642.40608-1-clamor95@gmail.com> <20261204061642.40608-2-clamor95@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 06:26:26 +0000 X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [High] leds: lm3533: use-after-free of led->cb.dev on unbind - [Low] leds: lm3533: incomplete &pdev->dev cleanup in lm3533_led_probe() - [Low] leds: lm3533: commit message omits probe reorder and ctrlbank devm action -- commit a4120acc50fac0321980afbff0b71dc5b97ab9b4 Author: Svyatoslav Ryhel > leds: lm3533: Clean up probe and use managed helpers > > Clean up the lm3533 LED driver probe and remove routines by adopting > managed device helpers and modernizing error handling: > > - Introduce a local `struct device *dev` variable to clean up repeated > `&pdev->dev` references. > - Use `dev_err_probe()` for cleaner error handling on invalid IDs and > LED class registration failures. > - Switch to `devm_led_classdev_register()` to automatically handle LED > class device unregistration, removing the need for manual cleanup in > error paths and the `remove` hook. > - Remove redundant `dev_dbg()` statements and cleanup unused cleanup > labels. > > Signed-off-by: Svyatoslav Ryhel [Severity: Low] Should the commit message also mention moving lm3533_led_setup() and lm3533_ctrlbank_enable() ahead of devm_led_classdev_register(), and adding the devm_add_action_or_reset() action for lm3533_disable_ctrlbank()? Those changes alter both the probe and teardown ordering. > diff --git a/drivers/leds/leds-lm3533.c b/drivers/leds/leds-lm3533.c > index d5997cbd88dfc..25b2a9225af9e 100644 > --- a/drivers/leds/leds-lm3533.c > +++ b/drivers/leds/leds-lm3533.c [ ... ] > @@ -683,14 +683,6 @@ static int lm3533_led_probe(struct platform_device *= pdev) > =20 > platform_set_drvdata(pdev, led); > =20 > - ret =3D led_classdev_register(&pdev->dev, &led->cdev); > - if (ret) { > - dev_err(&pdev->dev, "failed to register LED %d\n", pdev->id); > - return ret; > - } > - > - led->cb.dev =3D led->cdev.dev; > - > device_property_read_u32(&pdev->dev, "led-max-microamp", > &led->max_current); [Severity: Low] This isn't a bug, but this device_property_read_u32() call and the following one for "ti,pwm-config-mask" still use &pdev->dev instead of the new local dev variable. [ ... ] > @@ -700,28 +692,23 @@ static int lm3533_led_probe(struct platform_device = *pdev) > =20 > ret =3D lm3533_led_setup(led); > if (ret) > - goto err_deregister; > + return ret; > =20 > ret =3D lm3533_ctrlbank_enable(&led->cb); > if (ret) > - goto err_deregister; > - > - return 0; > - > -err_deregister: > - led_classdev_unregister(&led->cdev); > + return ret; > =20 > - return ret; > -} > + ret =3D devm_add_action_or_reset(dev, lm3533_disable_ctrlbank, &led->cb= ); > + if (ret) > + return ret; > =20 > -static void lm3533_led_remove(struct platform_device *pdev) > -{ > - struct lm3533_led *led =3D platform_get_drvdata(pdev); > + ret =3D devm_led_classdev_register(dev, &led->cdev); > + if (ret) > + return dev_err_probe(dev, ret, "Failed to register LED %d\n", pdev->id= ); > =20 > - dev_dbg(&pdev->dev, "%s\n", __func__); > + led->cb.dev =3D led->cdev.dev; > =20 > - lm3533_ctrlbank_disable(&led->cb); > - led_classdev_unregister(&led->cdev); > + return 0; > } [Severity: High] Can this cause a use-after-free of led->cb.dev on driver unbind? lm3533_disable_ctrlbank() is registered before devm_led_classdev_register(), and led->cb.dev is then overwritten with led->cdev.dev. On unbind, devres runs led_classdev_unregister() first, freeing led->cdev.dev via device_unregister(). lm3533_disable_ctrlbank() -> lm3533_ctrlbank_disable() then passes the dangling cb->dev to dev_dbg() (and dev_err() if regmap_clear_bits() fails). Keeping led->cb.dev pointing to dev or lm3533->dev instead of reassigning it to led->cdev.dev would avoid this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204061642.4060= 8-1-clamor95@gmail.com?part=3D1