From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D292D75E5D for ; Sat, 23 Nov 2024 19:36:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:Date:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6+/lj4r0cFKoqTMPP0UZbwboEUkdhzek/PAsJAMT+K0=; b=CxNZsCLzkP6/Cxs+7kNJM5Zi7P oJwYYiPT5s4JrJrMWVB10+fOrUAXFChR30uXaE52YTM8g/q+uWHoZAsfgN5bqeGaGUZCCLo7LVl91 fK3ZYE2s8bsDwSmtpivun2JJkTDJIgS4b/XVzFmW91ei9TtI66TQ3K84ZWcPNgKz7jwWqKeBlA73x XeE7HTSPj2mvLrR/Rn4wi32dlEZywbQkarnB5Qayaz2dROe+Pwg6fQrEgi+LVffaiQsqwLN8UVC0a 361fqCOvYZWYFANuZ3HXRSWDgdkoyGGfN7y7Qj0/AaxwG9hqACgTEqtuXOuiB6leGptDF+nsgsyB/ LfGhfn0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tEvvs-00000004mys-2kON; Sat, 23 Nov 2024 19:36:40 +0000 Received: from fgw22-7.mail.saunalahti.fi ([62.142.5.83]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tEvuw-00000004msK-0g57 for linux-arm-kernel@lists.infradead.org; Sat, 23 Nov 2024 19:35:43 +0000 Received: from localhost (88-113-25-143.elisa-laajakaista.fi [88.113.25.143]) by fgw22.mail.saunalahti.fi (Halon) with ESMTP id 1d611df1-a9d2-11ef-827a-005056bdf889; Sat, 23 Nov 2024 21:35:38 +0200 (EET) From: Andy Shevchenko Date: Sat, 23 Nov 2024 21:35:37 +0200 To: Javier Carrasco Cc: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: Re: [PATCH 07/18] leds: gpio: switch to device_for_each_child_node_scoped() Message-ID: References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> <20240927-leds_device_for_each_child_node_scoped-v1-7-95c0614b38c8@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-7-95c0614b38c8@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241123_113542_351707_45AD93C6 X-CRM114-Status: GOOD ( 10.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Fri, Sep 27, 2024 at 01:20:58AM +0200, Javier Carrasco kirjoitti: > Switch to device_for_each_child_node_scoped() to simplify the code by > removing the need for calls to fwnode_handle_put() in the error paths. > > This also prevents possible memory leaks if new error paths are added > without the required call to fwnode_handle_put(). ... > if (IS_ERR(led.gpiod)) { > dev_err_probe(dev, PTR_ERR(led.gpiod), "Failed to get GPIO '%pfw'\n", > child); > - fwnode_handle_put(child); > return ERR_CAST(led.gpiod); Here you may use dev_err_ptr_probe() > } -- With Best Regards, Andy Shevchenko