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=1795905603; b=WU/0eUk8P/FtOvV7hZYcosEusBpnT+P/YLw2rff6bpFOy/eidJ+WXFU/2wb2sINZnXcv 9gR5dZF84rstZD58byx95oxg+ni7jEajNAjQZESkS5oNvKEWmvwCmS9ma97QCrzqXojvg XuQquVfhVKW6iwPK3hiHoKAOUVJbmtwXDGwyTaAMOCbckqmwkt8CbrDhdirXJqZxVTruo qb9A8+VgUNq8UiNmttnvmSPMEUwPaz1qpCh9EQJkLg1925+3CeaqekOKE14S8pfqAnaol WhQPY2zJJiuJ/OV/9BE2WPOgLXm/WOHQCc5RMF2Q619pSsd67q2b2uxdIg/Fq1inFiA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795905603; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=/3+KzAYBVH7/NFUU2ofiQH5tbOr8w2AsAvtJbZl5tAw=; b=gDNZheVuCcElcWqtw7pZEl2OWtuepmozFLxfK+jtWSmFYNPeADX7mGjbLDE8Zw+2JhQ3 CDduuEOOeZmwWxPFhFazrxbO+6rum2Aogbz2t2UWSrhT6E/jcJ5+WKhfqMbNHCy/DGkvA dK7y3BphLQy7+YqSGNcs5lR6wEy081cWm/yapmWobAaG83cU9RJBAvrFQ6WAs5Of/fdh7 innhzjsBSQ/UoLHnHff56DwyQa01RwURunlO0+hPwCkz3OmcuGQ2fBgnC8huNQ9HTd35u ZjX91dCP4+uT50Ub1SCT6C+2uxOUzwaJ7X0rVdA7leu/+habBsqzywWdo1W0S0AQi5w== 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="UeS/Mvb3"; 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 7DC20606A31C for ; Sat, 28 Nov 2026 22:40:03 +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=UeS/Mvb3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20E0E1F000C1; Sat, 28 Nov 2026 22:40:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795905603; bh=/3+KzAYBVH7/NFUU2ofiQH5tbOr8w2AsAvtJbZl5tAw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=UeS/Mvb3vML3cw1LvFnjwGq9/qPXGBF11YK7SCKF9Lu+lOdjA2DfZLgsCpUuMpcLE SB65cLe1hnCPRUxFfgYOfQUVFK4z/wgyVwTJARsDR1dg7eYDpbOdU/XK4eVIn+i8xp AHIeGuSUmCCsa6FEFA81PA+iBfyhsxgi31r9F9Ko6fua4Nq2oi7rZKSEg37dwmy0bu JygCXXPSOaVMnyYlkyaS8k6ShPnzdIFPbTuQSTnuOnx1wY/7N9RFRSSjOqemc5uXHS hMnPFZy5BDYhsmeCrlnqMGo1ul8pp742j6n4wGYZ/hP9uu2e26Af4BaXTitxnExIgb wueU2oz8o/7Dw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] 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: <20261128223052.215375-1-t3127430@gmail.com> References: <20261128223052.215375-1-t3127430@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 28 Nov 2026 22:40:02 +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 4 potential issues to consider: - [High] leds: pca9532: missing led_classdev_unregister() in pca9532_configure() - [Medium] leds: pca9532: stale PCA9532_PWM1 state on error in pca9532_set_blink() - [Medium] leds: pca9532: ignored error return in pca9532_gpio_direction_input() - [Low] leds: pca9532: empty commit description body -- commit cfd64d8a31c7a13a716f2c043b0af231a835bd23 Author: Daniil Demakov > leds: pca9532: Propagate I2C errors > > Signed-off-by: Daniil Demakov [Severity: Low] This commit has an empty changelog body. Could a short description explaining what is changed and why be added? > diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c > index c8085427696ff..09735f06c8901 100644 > --- a/drivers/leds/leds-pca9532.c > +++ b/drivers/leds/leds-pca9532.c [ ... ] > @@ -257,9 +277,9 @@ static int pca9532_set_blink(struct led_classdev *led= _cdev, > if (err) > return err; > =20 > - pca9532_setled(led); > + err =3D pca9532_setled(led); > =20 > - return 0; > + return err; > } [Severity: Medium] Does returning an error here leave led->state stuck at PCA9532_PWM1? pca9532_update_hw_blink() sets led->state =3D PCA9532_PWM1 before pca9532_setled() runs. When pca9532_set_blink() returns a non-zero error, led_blink_setup() falls back to software blinking, but pca9532_set_brightness() ignores non-zero brightness updates while led->state =3D=3D PCA9532_PWM1: drivers/leds/leds-pca9532.c:pca9532_set_brightness() { if (value =3D=3D LED_OFF) { led->state =3D PCA9532_OFF; } else if (led->state =3D=3D PCA9532_PWM1) { return 0; /* Non-zero brightness shall not stop HW blinking */ } As a result, software blink ticks and manual non-zero brightness writes cannot turn the LED on. > @@ -328,15 +348,15 @@ static int pca9532_gpio_set_value(struct gpio_chip = *gc, unsigned int offset, > { > struct pca9532_data *data =3D gpiochip_get_data(gc); > struct pca9532_led *led =3D &data->leds[offset]; > - > + int err; > if (val) > led->state =3D PCA9532_OFF; > else > led->state =3D PCA9532_ON; > =20 > - pca9532_setled(led); > + err =3D pca9532_setled(led); > =20 > - return 0; > + return err; > } [Severity: Medium] Should pca9532_gpio_direction_input() also return the error from pca9532_gpio_set_value()? drivers/leds/leds-pca9532.c:pca9532_gpio_direction_input() { /* To use as input ensure pin is not driven */ pca9532_gpio_set_value(gc, offset, 1); return 0; } If pca9532_setled() fails when releasing the open-drain pin, pca9532_gpio_direction_input() discards the error and reports success while the pin may remain driven low. > @@ -442,14 +462,18 @@ static int pca9532_configure(struct i2c_client *cli= ent, > led->name); > goto exit; > } > - pca9532_setled(led); > + err =3D pca9532_setled(led); > + if (err) > + goto exit; > break; [Severity: High] If pca9532_setled() fails here, does jumping to exit leave led->ldev registered? led_classdev_register() has already succeeded for index i, and the exit label calls pca9532_destroy_devices(data, i), which only unregisters indices i - 1 down to 0: drivers/leds/leds-pca9532.c:pca9532_destroy_devices() { int i =3D n_devs; while (--i >=3D 0) { switch (data->leds[i].type) { ... case PCA9532_TYPE_LED: led_classdev_unregister(&data->leds[i].ldev); break; } When pca9532_probe() then fails, devres frees data while data->leds[i].ldev remains registered in the LED core, leading to a use-after-free. Calling pca9532_setled(led) before led_classdev_register() would avoid this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261128223052.2153= 75-1-t3127430@gmail.com?part=3D1