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=1796143809; b=cv3NgrNRCVuPdb31RnvXV8YDQ3l6dhDJIol0ZLINHDkBRTPr1XWVemlB2O+R9C9PmOvD iLCRYQJRZm+3qD/eEnzZlkBsbpkhTRVKI6Bz1LDQIg2Juy8GHHVZiwO84cdQ7YYz7WzSM AWkaycfZ2Yz6uBtCoXYe+0lmKjmvc4IVbxvsuo+zlAC0TydhmP1xJWfV17deA4Rr4r/cX eFGQ2WdhsDbzCHP5ufXeLX2GVUXEnAZP3ZMhtrx6hjxYg0BOofi8Dhyb9j9urT6n77lCe lblYxNo0osxuPeY0clK6Qh/HofQ5ZmodSc484dtAF2VreRK/cbq+V7hW6UFvPj9fvtw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796143809; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=ZHkPGZOXQnIbucAPz+ndrqy8ku7JvMwjYWvDe5PZQiU=; b=XV4J4PJK5LkPWN4hwdDV3EtkPMhNp/LQzgHeI6mqtowf8VCQmRpxI7osmIJNFQDXh1Xu 0ictclQKVElTuJ0ae3GTcfQmHid5V8STbkbX/X5YBCRxCr7M1fFp2vrbOMR4QV/TBVp15 C9QIynPsfY88Y1NEoREVM/BlPdQbGC9t+8S/7pQGakvuBgT4ac7foQ9UnO46vijlbbEFE B7X/wJoHngrQdcoO8p5lLMvYgvzpP3AbPTFHtQDAvWPrU2WuZ1PGXFF6ncRPHo/93OaLm XVLdYU3zH+AOrLLt9ILQVOR1UG6zIMMuR6OgyfavqXqi+PxIcO5ZVVfQb3AvD1HINjg== 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="eSutH7+/"; 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 2E412606A31A for ; Tue, 1 Dec 2026 16:50:08 +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=eSutH7+/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4D481F00893; Tue, 1 Dec 2026 16:50:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796143808; bh=ZHkPGZOXQnIbucAPz+ndrqy8ku7JvMwjYWvDe5PZQiU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=eSutH7+/G/jXCv+catLv7n3PJi5zMQcRzTk6r9Uv8gkqxMV5IcfZqQPgTYinYNjKl p1B0JBpkgrR/cw3Ri88pybjMYgm8lL6BTBAFWjFkIBox7WqkYL8ho2jNonzfplLfmx YDKYrrsUTVSKymiw2xAVjFww0L5ii7B3ayVnorMLm9SJklXCSgKris6VaZ2ejYbEEB 3seoa3wrZNSWE/V1+LHfMy8hHz1cqz2/YXTY1rsZndMe35BQN7f0kA5QnOHujor2F+ DFMrTR9bP9pq9QEPrwGk5NX5l5TMoF++BIAIqQR2pO9xYjJkBXn/fann1GQeGLVbds 5dXKvd+cIpgLg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] reset: gpio: Keep reset-gpio device under the GPIO controller device Reply-To: sashiko-reviews@lists.linux.dev To: "Birk Skyum" Cc: linux-gpio@vger.kernel.org In-Reply-To: <20261201-reset-gpio-parent-devlink-v1-1-5195e8b377c4@pm.me> References: <20261201-reset-gpio-parent-devlink-v1-1-5195e8b377c4@pm.me> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 16:50:08 +0000 X-Mailing-List: linux-gpio@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 1 potential issue to consider: - [High] reset: gpio: reparenting breaks gpio_shared_dev_is_reset_gpio() match It also noticed 1 related pre-existing issue this patch does not introduce: - [High] reset: spurious WARN and use-after-free on reset_create_gpio_aux_device() failure [1] -- commit 890ede247418cae89ef97a10e0ba05a7fd77ed0d Author: Birk Skyum reset: gpio: Keep reset-gpio device under the GPIO controller device This commit parents reset-gpio auxiliary devices under the GPIO controller device instead of the gpiochip device and adds a DL_FLAG_AUTOPROBE_CONSUMER device link so the reset-gpio device unbinds and re-probes across GPIO controller driver unbind and rebind cycles. > diff --git a/drivers/reset/core.c b/drivers/reset/core.c > index 38e189d04d09b..09bb7784c877b 100644 > --- a/drivers/reset/core.c > +++ b/drivers/reset/core.c [ ... ] > @@ -1070,9 +1070,20 @@ static int __reset_add_reset_gpio_device(struct fw= node_handle *fwnode, > } > =20 > lflags =3D GPIO_PERSISTENT | (flags & GPIO_ACTIVE_LOW); > - parent =3D gpio_device_to_device(gdev); > + gdev_dev =3D gpio_device_to_device(gdev); > properties[prop++] =3D PROPERTY_ENTRY_STRING("compatible", "reset-gpio"= ); > - properties[prop++] =3D PROPERTY_ENTRY_GPIO("reset-gpios", parent->fwnod= e, offset, lflags); > + properties[prop++] =3D PROPERTY_ENTRY_GPIO("reset-gpios", gdev_dev->fwn= ode, offset, lflags); > + > + /* > + * The reset-gpio device is never removed, but the GPIO device goes > + * away whenever the GPIO controller's driver unbinds, for example the > + * LPASS pin controller when the audio DSP restarts. A reset-gpio > + * device left under the old GPIO device can never bind again > + * ("driver_sysfs_add failed"). Put it under the device that provides > + * the GPIO controller instead, which stays, and link it to that > + * device below so it follows the controller's driver. > + */ > + parent =3D gdev_dev->parent ?: gdev_dev; [Severity: High] Does reparenting the reset-gpio auxiliary device to gdev_dev->parent break shared GPIO lookup in gpio_shared_dev_is_reset_gpio() when the gpio_chip has its own fwnode? In gpiolib-shared, entry->fwnode is the firmware node of the GPIO controller matched against &gdev->dev (which uses gc->fwnode when set), and gpio_shared_dev_is_reset_gpio() expects the reset-gpio device's parent to match that fwnode: drivers/gpio/gpiolib-shared.c:gpio_shared_dev_is_reset_gpio() { ... /* * Parent of the reset-gpio auxiliary device is the GPIO chip whose * fwnode we stored in the entry structure. */ if (!device_match_fwnode(parent, entry->fwnode)) return false; ... } On controllers where gc->fwnode differs from dev_fwnode(gc->parent) (such as multi-bank pin controllers with per-bank child DT nodes), device_match_fwnode() now checks gdev_dev->parent instead of gdev_dev and returns false. When reset_gpio_probe() requests the shared reset GPIO, gpio_shared_add_proxy_lookup() then hits WARN_ON(1) and fails the probe with -ENOENT. > =20 > /* Not freed on success, because it is persisent subsystem data. */ > rgpio_dev =3D kzalloc_obj(*rgpio_dev); > @@ -1097,6 +1108,17 @@ static int __reset_add_reset_gpio_device(struct fw= node_handle *fwnode, > if (ret) > goto err_del_swnode; [Severity: High] This problem wasn't introduced by this patch, but if reset_create_gpio_aux_device() fails in __auxiliary_device_add() after auxiliary_device_init() has succeeded, can error cleanup trigger a spurious WARN and a use-after-free [1]? drivers/reset/core.c:reset_create_gpio_aux_device() { ... adev->dev.release =3D reset_gpio_aux_device_release; ... ret =3D auxiliary_device_init(adev); if (ret) { ida_free(&reset_gpio_ida, id); return ret; } ret =3D __auxiliary_device_add(adev, "reset"); if (ret) { auxiliary_device_uninit(adev); ida_free(&reset_gpio_ida, id); return ret; } } auxiliary_device_uninit() calls put_device(), which invokes reset_gpio_aux_device_release() and triggers its unconditional WARN(1, ...) without freeing rgpio_dev. __reset_add_reset_gpio_device() then jumps to err_del_swnode and runs kfree(rgpio_dev) outside the device release callback, causing a use-after-free in kobject_delayed_cleanup() when CONFIG_DEBUG_KOBJECT_RELEASE is enabled. [1] https://sashiko.dev/#/bug/linux-c613c5b7-1804-46c9-9911-ed5179103296 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201-reset-gpio= -parent-devlink-v1-1-5195e8b377c4@pm.me?part=3D1