Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1133099pxj; Sat, 29 May 2021 04:21:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDH5BVq404BSsE3Mf5s+5KV7pJtsvFD8lGEfrnwZAsOlKOj1Zml4mjcG0G1oiUEie5++l5 X-Received: by 2002:a5d:9d0e:: with SMTP id j14mr10660905ioj.140.1622287275239; Sat, 29 May 2021 04:21:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622287275; cv=none; d=google.com; s=arc-20160816; b=OZzvWvW5wyNaCjMhW3Wgoo6z95Oxk+nnnodjnd9vsh63wXAS8C3rNc6z7JVq/0mSub RJmpAtpDBTux3U2lHdwMbYbRryjpPrShpyWocqnRx56vpKraTBD9dztNhbf4PVUjFe5d u2JKJiXXx26SXKmHhTyQiZ8ZzZWsG7TyAdzsQDwI5U7htCPkxVRAGCqpEKmRImvxxVkn tonV8Q3RtWip0ALS20dvZIBpvtnV15OD0xHpXFFmibQN9o/7+fL+SMH4VpAlaq92xudk nz85iveBxUWCf55FiWksUqHOEDntvC0YKOJCCnd0ou396Fock4+jVf2Yq4vR9EbTtlDr 0+FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from; bh=6bD+32HJh0esuu2A56G0OTZar/iJoE6ywUcPwj1dqAg=; b=BwL6Zmf/gTGK5xnilwDyN3m4XEg3SoJbtHyOX+RjSSKwTf8On0KKIwi6kk5d0fcfgu Se70fkQFEBFR2O8joyncPIFqXRsH6AyVpk5HGlxEpQpxprkMWnR0HhV6RIegurrrcppB CYrp+P4QCdd1aVSmIanOPBOB+J9a6P5FThVL5ROiGMDiVgS4uOhE4MuvMEGdxfmZlwVV f9mwWoFXCP+dx0yYQnNdQh8zVQ/875e+b1yJXL+oNSYi/HBVEpuZ0G1sToU8NNkLfott qlZ9tY9vC+IHDobNXJ/yA5EshlBXlYnUpphKCruRGHl8M5LzqL+mraZpevoarB5/QbDh i2YA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k6si7767642ion.34.2021.05.29.04.21.02; Sat, 29 May 2021 04:21:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229823AbhE2LV0 (ORCPT + 99 others); Sat, 29 May 2021 07:21:26 -0400 Received: from fgw21-7.mail.saunalahti.fi ([62.142.5.82]:38826 "EHLO fgw21-7.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229724AbhE2LVT (ORCPT ); Sat, 29 May 2021 07:21:19 -0400 Received: from localhost (88-115-248-186.elisa-laajakaista.fi [88.115.248.186]) by fgw21.mail.saunalahti.fi (Halon) with ESMTP id c2d479f8-c06f-11eb-9eb8-005056bdd08f; Sat, 29 May 2021 14:19:40 +0300 (EEST) From: Andy Shevchenko To: Pavel Machek , Andy Shevchenko , Amireddy Mallikarjuna reddy , Linus Walleij , Abanoub Sameh , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Krzysztof Kozlowski , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 04/13] leds: lgm-sso: Put fwnode in any case during ->probe() Date: Sat, 29 May 2021 14:19:26 +0300 Message-Id: <20210529111935.3849707-4-andy.shevchenko@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210529111935.3849707-1-andy.shevchenko@gmail.com> References: <20210529111935.3849707-1-andy.shevchenko@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org fwnode_get_next_child_node() bumps a reference counting of a returned variable. We have to balance it whenever we return to the caller. All the same in fwnode_for_each_child_node() case. Fixes: c3987cd2bca3 ("leds: lgm: Add LED controller driver for LGM SoC") Cc: Amireddy Mallikarjuna reddy Signed-off-by: Andy Shevchenko --- v2: simplified sso_led_dt_parse() fix (Pavel) drivers/leds/blink/leds-lgm-sso.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/leds/blink/leds-lgm-sso.c b/drivers/leds/blink/leds-lgm-sso.c index e63112d445eb..a27687e0fc04 100644 --- a/drivers/leds/blink/leds-lgm-sso.c +++ b/drivers/leds/blink/leds-lgm-sso.c @@ -633,8 +633,10 @@ __sso_led_dt_parse(struct sso_led_priv *priv, struct fwnode_handle *fw_ssoled) fwnode_for_each_child_node(fw_ssoled, fwnode_child) { led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); - if (!led) - return -ENOMEM; + if (!led) { + ret = -ENOMEM; + goto __dt_err; + } INIT_LIST_HEAD(&led->list); led->priv = priv; @@ -704,11 +706,11 @@ __sso_led_dt_parse(struct sso_led_priv *priv, struct fwnode_handle *fw_ssoled) if (sso_create_led(priv, led, fwnode_child)) goto __dt_err; } - fwnode_handle_put(fw_ssoled); return 0; + __dt_err: - fwnode_handle_put(fw_ssoled); + fwnode_handle_put(fwnode_child); /* unregister leds */ list_for_each(p, &priv->led_list) { led = list_entry(p, struct sso_led, list); @@ -733,6 +735,7 @@ static int sso_led_dt_parse(struct sso_led_priv *priv) fw_ssoled = fwnode_get_named_child_node(fwnode, "ssoled"); if (fw_ssoled) { ret = __sso_led_dt_parse(priv, fw_ssoled); + fwnode_handle_put(fw_ssoled); if (ret) return ret; } -- 2.31.1