From nobody Fri Sep 12 08:46:51 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9792C636CC for ; Sat, 11 Feb 2023 10:42:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229901AbjBKKmh (ORCPT ); Sat, 11 Feb 2023 05:42:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbjBKKmf (ORCPT ); Sat, 11 Feb 2023 05:42:35 -0500 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2700B311D6; Sat, 11 Feb 2023 02:42:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1676112134; bh=YWNKXJsGcCGSx3BeuPJ+DwSelvQ5DLVpRbP15fVAw0U=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=brMK4e3yl6tT6M4P6Jq1Jjx5RoM0dOgNE2WNL3D6+Fkto4hauTKf8hC829y4Z8k/3 qTnma4bpWzlQXaMwM7o1e5wYm0IPpVdLYZj63L6w8OUKTwXN/+Det6r1iNUFQ1alpz 7rR6yJdyiFIjQfRnNHUybEOHQZzmsstO1iJjLveQ= Received: by b-5.in.mailobj.net [192.168.90.15] with ESMTP via ip-206.mailobj.net [213.182.55.206] Sat, 11 Feb 2023 11:42:14 +0100 (CET) X-EA-Auth: KWivLFusfe4M1FPFEQqJeQo8HsYkZIK5ja/R4WdeOuBADd0RqXt/X9wMN3obLuKKdS3duyFYHD6akLmUX/+DPU2MGNdvswLc Date: Sat, 11 Feb 2023 16:12:07 +0530 From: Deepak R Varma To: Pavel Machek , Lee Jones , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar , Praveen Kumar , Deepak R Varma Subject: [PATCH] leds: qcom-lpg: Release node reference before returning Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The iterator for_each_available_child_of_node() increments the refcount of the child node it is processing. Release such a reference when the loop needs to breaks due to en error during its execution. Issue identified using for_each_child.cocci Coccinelle semantic patch. Signed-off-by: Deepak R Varma --- Please note: The proposed change is compile tested only. I do not have the necessary hardware to perform additional testing. Please suggest if there i= s an alternate means available to further test this change. drivers/leds/rgb/leds-qcom-lpg.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-= lpg.c index 67f48f222109..993fb9cf0204 100644 --- a/drivers/leds/rgb/leds-qcom-lpg.c +++ b/drivers/leds/rgb/leds-qcom-lpg.c @@ -1112,8 +1112,10 @@ static int lpg_add_led(struct lpg *lpg, struct devic= e_node *np) i =3D 0; for_each_available_child_of_node(np, child) { ret =3D lpg_parse_channel(lpg, child, &led->channels[i]); - if (ret < 0) + if (ret < 0) { + of_node_put(child); return ret; + } =20 info[i].color_index =3D led->channels[i]->color; info[i].intensity =3D 0; @@ -1291,8 +1293,10 @@ static int lpg_probe(struct platform_device *pdev) =20 for_each_available_child_of_node(pdev->dev.of_node, np) { ret =3D lpg_add_led(lpg, np); - if (ret) + if (ret) { + of_node_put(np); return ret; + } } =20 for (i =3D 0; i < lpg->num_channels; i++) --=20 2.34.1