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=1796365814; b=TdZl8GgBlJv9J83wCmZeMZyuAt6tY205C+z+vo+QmNQ2PJ8IUPpUeHFsMPZG1sUoK20S Sfe7BcgKAOon0TBAicra1hZIkMuIUenMR5ltdGSC5l1//bCI7k3IDzE47z+7jbYKgeFN+ mRvWhzFpbj6yZTZ3u6t+ez8PoSKNB7c7YuBLw19HnRSGQGKogFgYkTVL0YqZSDwEz8M6/ E5KM91ZsatUAxr8zhaGmMSeKnTJ3AiWnx63gbTYpjW8GndyqySbiryT41KHl8JUJdv/jo edjpNRFFlqVSACbJmMMPdFgCIH6v0kKgr2A7GMdML8HakPKhezzhNuHm4h6t02F2byA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796365814; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=eDp80hbaqKro6XLKogPsa87ejidOtWZuR72MJtsKDHk=; b=CPb3Y6cpbRmlfXY83BvSvwTA3TLUMQ/0I2G6Ukg3/x/1tzHv8UuKpb9FiicrAF1hrlR7 EWZsrNkydNWV2rWfOqDAc1UJHG+rKpOc/QTChxcGaEAjzTVRUAtUnuzQz+WuTyFxZpZEr WP5B1ZAJjlxwOMxBDkVrQ4U8xzylJPkbrQ29CA5MikMugkDzwi0cw/5fIP63OiGb7CXyl jzGeN+UF76SejI+rybiZOM0H7EDr13qJtArikHfKUh72bxkl/LRBE0ten2nIQuqA510i5 cvjbqUcSL5olFbCFePTRk+h3ZrZ5ipcpczx8RD3Bj+L0Ets4Kr7aEPoPW4ZQkkzz8rg== 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=dZ4brCcu; 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 7529D606A32D for ; Fri, 4 Dec 2026 06:30:14 +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=dZ4brCcu Received: by smtp.kernel.org (Postfix) with ESMTPSA id 397051F00933; Fri, 4 Dec 2026 06:30:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796365814; bh=eDp80hbaqKro6XLKogPsa87ejidOtWZuR72MJtsKDHk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=dZ4brCcuMUSeNv2DrbnVTW2C+ennmxftCih+AOi8pnldkoEi6VAym/GMlAyI8p8DS u4nE2AKOUJfTObkD8qB0Ow3a+BpE+cPjulqWiOJs/Vlyx37FEdY1bJ5ohjnk+iuTW2 yZa3IhQ9qFbaWvJZ1MyEDHCiFp9946op2WazEzCR0D4KAfu0nfTzjVZIxB58u/64w9 /9SqUA0yj52x8VXWRDjiyge+9kC915/uNQ4Lv1DXxC8Iq9nnYp00/6GxLMAfXIrb9v gVbGunPrWL6T/UXam0SL5qxWQHSfxDiMSCRAH0f4idW+XDFMJirGQ2eIBt85th/SBB 6ngXDs8tLM6vg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 2/2] leds: lm3533: Support getting LED sources from DT Reply-To: sashiko-reviews@lists.linux.dev To: "Svyatoslav Ryhel" Cc: linux-leds@vger.kernel.org, lee@kernel.org In-Reply-To: <20261204061642.40608-3-clamor95@gmail.com> References: <20261204061642.40608-1-clamor95@gmail.com> <20261204061642.40608-3-clamor95@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 06:30:13 +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: lm3533_led_setup() reads led-sources from parent MFD device - [High] leds: lm3533: use-after-free of led->cb.dev in lm3533_disable_ctrlbank() - [Low] leds: lm3533: lm3533_led_setup() formats unsigned u32 leds[i] with %d -- commit ec80b3ed37ca724fa304228edf3fde088c418ee7 Author: Svyatoslav Ryhel leds: lm3533: Support getting LED sources from DT This commit adds support for reading the led-sources device tree property in lm3533_led_setup() to configure the control bank to LVLED output mapping in LM3533_REG_OUTPUT_CONF1 and LM3533_REG_OUTPUT_CONF2. > diff --git a/drivers/leds/leds-lm3533.c b/drivers/leds/leds-lm3533.c > index 25b2a9225af9e..90fd9a331e2b2 100644 > --- a/drivers/leds/leds-lm3533.c > +++ b/drivers/leds/leds-lm3533.c [ ... ] > @@ -622,8 +632,60 @@ static const struct attribute_group *lm3533_led_attr= ibute_groups[] =3D { > =20 > static int lm3533_led_setup(struct lm3533_led *led) > { > + struct device *dev =3D led->cb.dev; > + u32 leds[LM3533_LVLED_COUNT] =3D { }; > + u32 output_cfg_shift =3D 0; > + u32 output_cfg_val =3D 0; > + u32 output_cfg_mask =3D 0; > + int num_leds; > int ret; > =20 > + /* > + * If led-sources property is not set then either this Control Bank uses > + * its default LVLED or is not linked to any LVLED at all. > + */ > + num_leds =3D device_property_count_u32(dev, "led-sources"); [Severity: High] Does this query led-sources on the parent MFD device instead of the LED child platform device? lm3533_led_probe() sets led->cb.dev to lm3533->dev (the parent I2C device) before calling lm3533_led_setup(), whereas led-sources belongs on the child ti,lm3533-leds node attached to &pdev->dev. On valid device trees, device_property_count_u32() fails, num_leds is clamped to 0, and LM3533_REG_OUTPUT_CONF1 and LM3533_REG_OUTPUT_CONF2 are never updated; dev_err_probe() also logs against the parent I2C device. Passing &pdev->dev into lm3533_led_setup() would fix this. [ ... ] > + for (int i =3D 0; i < num_leds; i++) { > + if (leds[i] > LM3533_LVLED_INDEX_MAX) > + return dev_err_probe(dev, -EINVAL, > + "LVLED index exceeds maximum %d: %d\n", > + LM3533_LVLED_INDEX_MAX, leds[i]); [Severity: Low] Should the second format specifier be %u instead of %d since leds[i] is a u32? Values at or above 0x80000000 would otherwise be printed as negative numbers. [Severity: High] Can lm3533_disable_ctrlbank() cause a use-after-free of led->cb.dev on unbind or MFD removal? In commit "leds: lm3533: Clean up probe and use managed helpers", lm3533_led_probe() registers lm3533_disable_ctrlbank before devm_led_classdev_register() and then aliases led->cb.dev to led->cdev.dev: drivers/leds/leds-lm3533.c:lm3533_led_probe() { ... ret =3D devm_add_action_or_reset(dev, lm3533_disable_ctrlbank, &led->cb); if (ret) return ret; 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); led->cb.dev =3D led->cdev.dev; ... } Because devres runs in LIFO order, devm_led_classdev_release() calls led_classdev_unregister() -> device_unregister(led_cdev->dev) and frees led->cdev.dev first. lm3533_disable_ctrlbank() -> lm3533_ctrlbank_disable() then dereferences the freed cb->dev in dev_dbg() and dev_err(). Keeping led->cb.dev pointing to &pdev->dev, or registering lm3533_disable_ctrlbank after devm_led_classdev_register(), avoids this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204061642.4060= 8-1-clamor95@gmail.com?part=3D2