Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp755160pxk; Thu, 17 Sep 2020 15:39:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCqTAOoyZSBL5Q2a6Y429j3yJo2B0JqeBFMoGYKNQefW3q6rvL2oTqWqlgZtQtO5e8ZBXI X-Received: by 2002:a17:906:249b:: with SMTP id e27mr32689142ejb.105.1600382371775; Thu, 17 Sep 2020 15:39:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600382371; cv=none; d=google.com; s=arc-20160816; b=FPhUqyyWWO12LQuKgS0+vutWMCa4G0niq0xeBLotFxHsO0K7LqxMKnEnVS7oBvmv3l 2JOoAplTSa7Jz7igyqAbqOWmCQTlg427Tg0TBiD6b65ClPQJGvV/yAByJ7ntnb0XSmja WQgp7F0Xr1K+4eJNUacg7YJS0T3O7Pg0dhYgStCW7bhVlUcJMFea9AKEL2u+qXWcJnHf c2hvWOzVvzMKm+uxLPKq314LWasyw881CpTNPKEHTDUczm8ggMcIR76tIX+qF12q8dFA AB0BgnML+68/HRld4R0es4bJPudKAYgFtrzw7k0fcdr9hkDZUYITRuU/TUTAHP77j0HP OAXQ== 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:cc:to:from :dkim-signature; bh=F7e1DLlzsMGalaf9aEsNhLvoHIIAj+LtFz04VT9ZMkg=; b=tiD+xPwLFpx97An/Ug6yPb7pPb3aBGxLSx59Ayj8Jx2tlVT6DEiuI6+pWkwM0b/pHq WMv0EgdlJpYn6R83szdmbFrNqlnLP3jaHcUrptqvY54vTCKC8AY0SdrRORJPAnfUK65w VQSn0sBAOB6A+vCYM/z5ND09gf4azPIRMKVNoudLwhOU5W/JQ3zHXR/G/EXot+3L7qPP q+CskIXlxIOM0UZ/k2zLWxvLvAQo7PvsHuiM7Z1n7KtE95OfN1q4dvPMBIqYCpZeSOTi GuaTEAo+0Y11HB+/I2fI0sMvumNL1UoRGS4Ek8zg0a/4Li8oWMH3eS2xuGOeATzV4sNn yQMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nic.cz header.s=default header.b=VBvCHPmM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nic.cz Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z14si967730ejj.185.2020.09.17.15.39.08; Thu, 17 Sep 2020 15:39:31 -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; dkim=pass header.i=@nic.cz header.s=default header.b=VBvCHPmM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nic.cz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726913AbgIQWg6 (ORCPT + 99 others); Thu, 17 Sep 2020 18:36:58 -0400 Received: from lists.nic.cz ([217.31.204.67]:35542 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726118AbgIQWd7 (ORCPT ); Thu, 17 Sep 2020 18:33:59 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id D01EE140A94; Fri, 18 Sep 2020 00:33:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1600382035; bh=5wo607a85PZ8EGCxuDc4OP1bAfnLn3jrieSehirzD8s=; h=From:To:Date; b=VBvCHPmMP1qIPa4bt2pFY6SsW5rtR7R4Y9gmaph+JqZZH1gr+VaNZRT2UXf0PvyKy BVsoFiWzNFAOHN9sPpeGJtI0t3mXAjwkDMm9FvdLSzQlTiKEKJeCMmJdO1iExCOvgo 4yz0IxMDDbOfm9QxBMW9HWOu9ct8nWTTnD4W+gHE= From: =?UTF-8?q?Marek=20Beh=C3=BAn?= To: linux-leds@vger.kernel.org Cc: Pavel Machek , Dan Murphy , =?UTF-8?q?Ond=C5=99ej=20Jirman?= , linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org, =?UTF-8?q?Marek=20Beh=C3=BAn?= , Nikita Travkin , Milo Kim Subject: [PATCH leds v2 09/50] leds: various: fix OF node leaks Date: Fri, 18 Sep 2020 00:32:57 +0200 Message-Id: <20200917223338.14164-10-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200917223338.14164-1-marek.behun@nic.cz> References: <20200917223338.14164-1-marek.behun@nic.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.nic.cz X-Spam-Status: No, score=0.00 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix OF node leaks by calling of_node_put in for_each_available_child_of_node when the cycle breaks or returns. Signed-off-by: Marek BehĂșn Cc: Nikita Travkin Cc: Milo Kim Cc: Dan Murphy --- drivers/leds/leds-aw2013.c | 4 +++- drivers/leds/leds-lp55xx-common.c | 8 ++++++-- drivers/leds/leds-turris-omnia.c | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/leds/leds-aw2013.c b/drivers/leds/leds-aw2013.c index 9df7de042bca2..927c5ba32592f 100644 --- a/drivers/leds/leds-aw2013.c +++ b/drivers/leds/leds-aw2013.c @@ -305,8 +305,10 @@ static int aw2013_probe_dt(struct aw2013 *chip) ret = devm_led_classdev_register_ext(&chip->client->dev, &led->cdev, &init_data); - if (ret < 0) + if (ret < 0) { + of_node_put(child); return ret; + } i++; } diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index 50f7f5b874636..81de1346bf5d6 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c @@ -614,8 +614,10 @@ static int lp55xx_parse_multi_led(struct device_node *np, for_each_available_child_of_node(np, child) { ret = lp55xx_parse_multi_led_child(child, cfg, child_number, num_colors); - if (ret) + if (ret) { + of_node_put(child); return ret; + } num_colors++; } @@ -681,8 +683,10 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, for_each_available_child_of_node(np, child) { ret = lp55xx_parse_logical_led(child, cfg, i); - if (ret) + if (ret) { + of_node_put(child); return ERR_PTR(-EINVAL); + } i++; } diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index b2add494af14d..c276969137d7f 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -236,8 +236,10 @@ static int omnia_leds_probe(struct i2c_client *client, led = &leds->leds[0]; for_each_available_child_of_node(np, child) { ret = omnia_led_register(client, led, child); - if (ret < 0) + if (ret < 0) { + of_node_put(child); return ret; + } led += ret; } -- 2.26.2