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=1796229027; b=JrpS1Tu4muYb7lJww9HanpEiFk2ahfUG56QcHXc68y1+NzVzEbfqbjxnGrNf9f2Kzl0P zbE48hvoXliq28MHKpx+SvLmZdX6M4ymVCoDkVj2la4inKclF1ovtBxGez9yyUEKFjxNL Tfc4oTr0e4GZ7GnVaeEKbnnfj/ePxTsAFnUx8JXzHozKt0FvQU6a7VszJfSG7nDoUEC91 7dzwLZLvIzdac4zvpyLHG/sb9nfhl2LVuSfx9fF43EyZOPXiLejaLc0DDuyT4A65D929T tvFoukAwL2ztKCtcl0deX0Qi4ljYT7ZSoXbTWtTbyBcND2T0vkpvN3yoaY85DxAyU8w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796229027; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To: X-AI-Review-Draft; bh=tEuTr8mnw+rWwBGk05gHYN21htdLq9VY2IucQzwVM7A=; b=0EYtneEgDhcYSqLR7T3jZq87L3wMcQ3f3hgo5odnNWo4BYc5qf2XD780/t/prRLseyay 5hFVwLbeh03vs/tdyauTva01mHfUT1AltDQRf7tk0V/sHivX+keHsv+4NNksYl9BdJzws 583nr9EwOzba//7SxvSeEDIqqT2ESpBeJRWmoSPvpqtVbDyZ9w6jz7uCLJOchxWO8PfvI uoZdGGMPQ3qrbl1pk81Cn/ouUNwaEGrwgIEbEnm6L5rMnUjMrf4OQMGypZSwZrNzfPu3h wHWGYOD2hbd0MmDjz9lInLp3b0pFwxnoYjZ6ZnPCpvY/EQDy0YlcXq7zNnxzn/EXqKw== 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=oPuEnPaf; 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 376CF606A31A; Wed, 2 Dec 2026 16:30:26 +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=oPuEnPaf Received: by smtp.kernel.org (Postfix) with ESMTPSA id 417D61F00896; Wed, 2 Dec 2026 16:30:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796229026; bh=tEuTr8mnw+rWwBGk05gHYN21htdLq9VY2IucQzwVM7A=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=oPuEnPafLU0l+/XB3m0wnUK+Sc2Sne7knrc3uBArHJHFfsI2fsegcn41K9xEJ9YK0 4LYzK8JaiKtNH4Il2hU0fieMYGhET4pJpwQcXY6mIQtv3G2C9u2WscdLnvbXDtGvpO bXPBZT0CP73AE7tujK8hLMou8R9g1N53Nfqx2aQ+jIJ0tiSlBfgWnl/MivjlvzjeUB YrDpFY8A0KVvsnxy+QPtoV0KNqXhxvs2UaBcbSJObQLqwGraT+NDRQU8Fro+RXa8T5 bfjggDw2IwRTXccxcwsyQXPELbp9KSy/cIv/yMbhMQlmiuvCOZHt3GPoH7fa+0b/ir YHFwCOPlw82bA== Date: Wed, 2 Dec 2026 16:30:22 +0000 From: Lee Jones To: Cong Nguyen Cc: Pavel Machek , ChiYuan Huang , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] leds: rt4505: Put the child node reference Message-ID: <179568524585.32537.8387613396737254401@kernel.org> References: <20261125130318.2590336-1-congnt264@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261125130318.2590336-1-congnt264@gmail.com> X-AI-Review-Draft: <20261125130318.2590336-1-congnt264@gmail.com> On Wed, 25 Nov 2026, Cong Nguyen wrote: > rt4505_probe() gets the LED child node with device_get_next_child_node(), > which returns it with its reference count raised. The driver never calls > fwnode_handle_put() on it, so the reference is leaked on every probe error > after that point and on a successful probe once the device is removed. > The v4l2 flash sub-device takes its own reference on the node, and the LED > class device only stores the pointer. > > Drop the reference with a device managed action registered right after the > node is taken, so it is released after the LED class device that was > registered later has been unregistered. leds-rt8515 puts the node of the > same kind after registering its LED and flash sub-device. > > Fixes: d9dfac5419d0 ("leds: rt4505: Add support for Richtek RT4505 flash LED controller") > Signed-off-by: Cong Nguyen > --- > drivers/leds/flash/leds-rt4505.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/leds/flash/leds-rt4505.c b/drivers/leds/flash/leds-rt4505.c > index 6a47760645f1..d397b1237c93 100644 > --- a/drivers/leds/flash/leds-rt4505.c > +++ b/drivers/leds/flash/leds-rt4505.c > @@ -338,6 +338,11 @@ static void rt4505_init_flash_properties(struct rt4505_priv *priv, > flash->ops = &rt4505_flash_ops; > } > > +static void rt4505_child_put(void *data) > +{ > + fwnode_handle_put(data); > +} Do we need this? Both led_classdev_register_ext() and v4l2_flash_init() take their own reference on 'init_data.fwnode' if they need to keep it around, so we only need the reference during rt4505_probe(). What if we declare 'child' with: struct fwnode_handle *child __free(fwnode_handle) = NULL; ... and let cleanup.h drop it when rt4505_probe() returns? > static int rt4505_probe(struct i2c_client *client) > { > struct rt4505_priv *priv; > @@ -370,6 +375,11 @@ static int rt4505_probe(struct i2c_client *client) > dev_err(priv->dev, "Failed to get child node\n"); > return -EINVAL; > } > + > + ret = devm_add_action_or_reset(priv->dev, rt4505_child_put, child); > + if (ret) > + return ret; > + > init_data.fwnode = child; > > rt4505_init_flash_properties(priv, child); > -- > 2.25.1 > > -- Lee Jones