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=1795911101; b=ueHSufYC5oowczDhd0xhmZagVgBXH5RMlU246fHnrD6AZfEWOM6tUKaIBCBW1TlWE6RI jQ2pY+QMvAXkuW8BE2ZrvxvjRE0YtqOh5MhfQaW+6rAM2p2ktrYVBoMfu02GdVdsZdgcO rYV1iqh8wrI7ICgDpTB0OEp/TuU+tUXCUqZ4iTdnNIrIbAX7Ltq2s5zH3D0ioazzE8Rtp cmRWhgKooEygOp/ugQniMFiVjc0wvvoZw6lMSHUVHkW8pMjZUvk8n5vLo9naeR8uBG5mZ 32r5fk9VIg16H4m22nvZx1S8hCNlq+mxPVwUBcHjrjhn22Fgr2ilVhxVHvdYN6kC1Dw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795911101; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=ULr594tZNeNs+L0WxLeXAsUgpwNfFRf5/CRllbxPILA=; b=V4iCqWe0RAVgi9XzeStXgg3rYEpt5w/Bo7vgMuNuIG26GEO9gvdrZFhmbi0nUmXWx7dG q/i8jeytpdZqlb8I4Nznz6pMoPraNgDH7prF5OdbEoDnlYopWWQj6dyHXTfik5DdUWN+n xw76tnbVuahJNBBEWBs8x+BGyogm0swwIupkF456d3RUHzFJz59T7DzdLWloeJbnUj2VY Q8hfgGp0k1tGahqDo8LLb+ZpBgg0AC8r+UhPt8N0SiQnzrnlPjFlbEbQB6DGsE4kOPutG ucl615Qg8PZzD+ARabXQ/4eem/NR9AQo497iuFnO0BDwlxwK8GQt37HA85HJFrGFDAQ== 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=jSefXB8Z; 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 BAB63606A31C for ; Sun, 29 Nov 2026 00:11:41 +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=jSefXB8Z Received: by smtp.kernel.org (Postfix) with ESMTPSA id 310EB1F000C1; Sun, 29 Nov 2026 00:11:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795911101; bh=ULr594tZNeNs+L0WxLeXAsUgpwNfFRf5/CRllbxPILA=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=jSefXB8Zf9dOOBovCNzsI3l2RwnNFBG3d54glGzdkTj/66WirWY4U2n9WSXtdFnCX Y783UhT7Op+TGP33BglJ2IBF/ay5teMzoWD/ZPzIhKj4saKf0SkMPZQf4dDjH/M6+W Ygucu+g2R+dzNeFqJrUX7ffiLRLLbrd98HXO3xDOlnwzZ6yXAL27sWs72K3EFUalbi VsgP6sggEgeBGxROUz4W7VQc3Gz9So/VwZLdFDb+E9KOajnIsbRlixbGMW6u51V6WI 7SRqSi13QW3BU1XVoRd8pca+3U1ko+w7OyBqsojtvOWHBh6tQkZ1S+1RnKk64BrBp6 mMkcuGZ2DI8Fg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4] leds: pca9532: Propagate I2C errors Reply-To: sashiko-reviews@lists.linux.dev To: "Daniil Demakov" Cc: linux-leds@vger.kernel.org, lee@kernel.org In-Reply-To: <20261128235735.246391-1-t3127430@gmail.com> References: <20261128235735.246391-1-t3127430@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 00:11:40 +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 2 potential issues to consider: - [Medium] leds: pca9532: unrestored led->state on error in pca9532_set_brightness() - [Medium] leds: pca9532: unlocked led->state update and rollback in pca9532_set_blink() -- commit de45e00e83780f08043196b7fb8ea56f8bb90c4f Author: Daniil Demakov leds: pca9532: Propagate I2C errors This commit checks SMBus read and write return values in pca9532_setled(), propagates errors to callers, configures LEDs before registering their class devices, and restores led->state if hardware blinking setup fails. > diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c > index c8085427696ff..1c85e97e964b5 100644 > --- a/drivers/leds/leds-pca9532.c > +++ b/drivers/leds/leds-pca9532.c [ ... ] > @@ -196,7 +216,7 @@ static int pca9532_set_brightness(struct led_classdev= *led_cdev, > } > if (led->state =3D=3D PCA9532_PWM0) > pca9532_setpwm(led->client, PCA9532_PWM_ID_0); > - pca9532_setled(led); > + err =3D pca9532_setled(led); > return err; > } [Severity: Medium] Should pca9532_set_brightness() restore led->state when pca9532_calcpwm() or pca9532_setled() fails, the same way pca9532_set_blink() does? led->state is updated to PCA9532_OFF, PCA9532_ON, or PCA9532_PWM0 before programming the hardware. If the SMBus transfer in pca9532_setled() fails, led->state remains out of sync with the hardware register, which skews PWM0 duty-cycle averaging in pca9532_calcpwm() and hardware blink checks in pca9532_set_brightness() and pca9532_update_hw_blink(). pca9532_gpio_set_value() similarly leaves led->state modified when pca9532_setled() fails. > @@ -242,6 +262,7 @@ static int pca9532_set_blink(struct led_classdev *led= _cdev, > struct pca9532_led *led =3D ldev_to_led(led_cdev); > struct i2c_client *client =3D led->client; > struct pca9532_data *data =3D i2c_get_clientdata(client); > + int old_state =3D led->state; > int err; > =20 > if (!data->hw_blink) > @@ -255,11 +276,18 @@ static int pca9532_set_blink(struct led_classdev *l= ed_cdev, > =20 > err =3D pca9532_update_hw_blink(led, *delay_on, *delay_off); > if (err) > - return err; > + goto restore_state; > =20 > - pca9532_setled(led); > + err =3D pca9532_setled(led); > + if (err) > + goto restore_state; > =20 > return 0; > + > +restore_state: > + led->state =3D old_state; > + > + return err; > } [Severity: Medium] Can saving and restoring led->state without holding data->update_lock race with pca9532_set_brightness()? data->update_lock only protects the SMBus calls inside pca9532_setpwm() and pca9532_setled(). pca9532_set_blink() runs in sysfs or trigger context while pca9532_set_brightness() runs on set_brightness_work: CPU0 CPU1 (kworker) pca9532_set_blink() old_state =3D led->state; pca9532_update_hw_blink() led->state =3D PCA9532_PWM1; pca9532_setpwm() pca9532_set_brightness(..., LED_OFF) led->state =3D PCA9532_OFF; pca9532_setled() pca9532_setled() -> fails led->state =3D old_state; <-- overwrites PCA9532_OFF with stale state If pca9532_setled() in pca9532_set_blink() instead succeeds in that window, it writes PCA9532_OFF to hardware while returning 0 as if hardware blinking were active. Also, while led->state is transiently PCA9532_PWM1 before a failing pca9532_setled() rolls it back, a concurrent non-zero pca9532_set_brightness() hits the led->state =3D=3D PCA9532_PWM1 early retu= rn and drops the brightness update. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261128235735.2463= 91-1-t3127430@gmail.com?part=3D1