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=1796281900; b=Yyb3Gudi6sqFongXxuNgQrjCz9E05c3HqDNiBOwfNpxiR7P7JKEAGNHLPmWbQPVkxPN0 DPklkUTYsBXuP6/MaMoEC2oF3S6D+HtqYlySMEAG+KOVxFobDVUqulw2hbc1PqHCqiTPW YPVD97mz02mHcoxI1F7kFagrAseNJdZJlnOxbfDEOGrMhO99yx/hDxvOaTojTU+WAZ6JK 5sIWRwmjFixebEN7R4Qj98RaKBqCGMPyBfqUQvu1MiyzoGhxJDq8APIrB0pYZ9F2orrsG O1U7h8uoePrC2qtN8Ch1u8GzB81RW2aQt6wGuHyvCmC1LOGXAlH1PL1Z1L5Umce5r2Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796281900; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=97jjaehoFkJXFbZ1N9UG4T96pfe6xkTcNPl9aLHbtRo=; b=lmQOJ0ozYwWdFBQTOWV6ATU03RXAOkGq5uC63S/MXSWE1ZOaRGVneQReJ1/pb6GpZkQL u7KuGx80pKzC3PNy+u2jn2deDUNceHLuED29Q9UGqdPYlW43DO/vFL+7cKuSVxDz7qst9 EtU3Lfrkxh299PJ7sf8G4+pQ9nPdC5qGgsaLJ+2V11y8IDMzYe/Jkx9epKZWS2UoLgMQJ tX8GqZlZRz4G+Na5ZtRWfTW6nMNH4aFSC3NORjF1qcHR5NECvITA10Z4jkTh7bPD+3XGh gmM6CtTM96Dy9zw/wqkPAlmY6f87uXZOD+6lacEdyunwgepMfO0oyKhthU24cxWK2pQ== 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=oIBx+uHd; 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 83376606A32D for ; Thu, 3 Dec 2026 07:11:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oIBx+uHd Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E98A1F00896; Thu, 3 Dec 2026 07:11:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796281900; bh=97jjaehoFkJXFbZ1N9UG4T96pfe6xkTcNPl9aLHbtRo=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=oIBx+uHdQS7HLRG6Frl+gGDMHWLDRXaPbegQG8difgQ862FBbLdzC+SE/hRJbg+TW ezjyQIg34gCJi+HFo0I2gTiqyn/U1u/qm8Sm6KBJd2kubhe9QAJVVrxt8DeeK4OUsc xzcQanC8zDG9f2PNLCuwLFlYCfC0SczcF7uv8Ec2rYH1QxqhipFH+XUFg02EEW9Alf JH1kobnhVgVR7JcbMGrtMcMfNrnJps+vBdbBw5iajRANyeHrvIgewC0i7V+9Mt4fqR WhxsmvXHME43rrqDz+5L0SEaeaNu41p5dXcHLFzLV8QPvyKrjwS10apreUALrEjDAx 4KcXufjO1jCzw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 6/6] gpio: cros-ec: Fix firmware node reference count underflow Reply-To: sashiko-reviews@lists.linux.dev To: "Dmitry Torokhov" Cc: linux-gpio@vger.kernel.org In-Reply-To: <20261202-gpio-arizona-fwnode-fix-v1-6-3899179bf9d1@gmail.com> References: <20261202-gpio-arizona-fwnode-fix-v1-0-3899179bf9d1@gmail.com> <20261202-gpio-arizona-fwnode-fix-v1-6-3899179bf9d1@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 07:11:39 +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: - [Medium] gpio: cros-ec: unsynchronized device_set_node() mutation on live device -- commit f1ff3a2fe4430374ca0d36040d3e5873f66a4112 Author: Dmitry Torokhov gpio: cros-ec: Fix firmware node reference count underflow This commit takes a firmware node reference when attaching the EC protocol device's fwnode to the cros-ec-gpio platform device, and registers a devm action to clear it and drop the reference on unbind. It also sets gc->fwnode explicitly. > diff --git a/drivers/gpio/gpio-cros-ec.c b/drivers/gpio/gpio-cros-ec.c > index d06d74bd86d88..4a77ff3acd54b 100644 > --- a/drivers/gpio/gpio-cros-ec.c > +++ b/drivers/gpio/gpio-cros-ec.c > @@ -155,18 +155,39 @@ static int cros_ec_gpio_ngpios(struct cros_ec_devic= e *cros_ec) > return response.get_count.val; > } > =20 > +static void cros_ec_gpio_put_fwnode(void *data) > +{ > + struct device *dev =3D data; > + struct fwnode_handle *fwnode =3D dev_fwnode(dev); > + > + device_set_node(dev, NULL); > + fwnode_handle_put(fwnode); > +} > + > static int cros_ec_gpio_probe(struct platform_device *pdev) > { > struct device *dev =3D &pdev->dev; > struct device *parent =3D dev->parent; > struct cros_ec_dev *ec_dev =3D dev_get_drvdata(parent); > struct cros_ec_device *cros_ec =3D ec_dev->ec_dev; > + struct fwnode_handle *fwnode =3D dev_fwnode(cros_ec->dev); > struct gpio_chip *gc; > int ngpios; > int ret; > =20 > - /* Use the fwnode from the protocol device, e.g. cros-ec-spi */ > - device_set_node(dev, dev_fwnode(cros_ec->dev)); > + if (!dev_fwnode(dev) && fwnode) { > + /* > + * Use the fwnode from the protocol device, e.g. cros-ec-spi, > + * so acpi_gpiochip_add() sees its ACPI companion. Clear it on > + * unbind so platform_device_release() does not drop a parent > + * reference or tear down a shared software node. > + */ > + device_set_node(dev, fwnode_handle_get(fwnode)); > + ret =3D devm_add_action_or_reset(dev, cros_ec_gpio_put_fwnode, > + dev); > + if (ret) > + return ret; > + } [Severity: Medium] Can mutating dev->fwnode and dev->of_node with device_set_node() here race with lockless sysfs readers on the live platform_device? The cros-ec-gpio platform_device is already registered in sysfs during probe, and remains live during driver unbind or probe failure when cros_ec_gpio_put_fwnode() clears dev->fwnode and dev->of_node to NULL. Both paths only hold device_lock(dev) and perform plain stores. Sysfs uevent readers access dev->of_node without device_lock(dev) or READ_ONCE(). On DT systems, clearing dev->of_node while a reader is in of_device_uevent_modalias() triggers a KCSAN data race and lets the reader reload NULL after its initial check: CPU0 CPU1 uevent_show() ... of_device_uevent_modalias() if (!dev->of_node) /* false */ add_uevent_var(env, "MODALIAS=3D") unbind_store() ... cros_ec_gpio_put_fwnode() device_set_node(dev, NULL) of_modalias(dev->of_node, ...) <-- reloads NULL Passing NULL to of_modalias() emits a malformed MODALIAS=3Dof:N(null)T(null) uevent entry (and of_device_uevent() similarly emits OF_FULLNAME=3D(null)). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202-gpio-arizo= na-fwnode-fix-v1-0-3899179bf9d1@gmail.com?part=3D6