Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1134022pxj; Sat, 29 May 2021 04:22:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4AqOqVneqN01b3SUu7DJwkH7BqmFR6bYJwpNW8vAI4WdhB+7UNz5QBJFThWYGpRlKB9xn X-Received: by 2002:a92:da8b:: with SMTP id u11mr10584407iln.135.1622287374341; Sat, 29 May 2021 04:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622287374; cv=none; d=google.com; s=arc-20160816; b=h9INq8UJDQPCIGeN4qUUewPKqsHDCwNjglPFaCnwaZymvq4eXTXIKo2kndzQllvcgD df46wtkGqnPUCbocC5R00E2XykftctnHcFVReAcdbZuUC0qGyLCJR0GZLpCwWXY+3WdH vpmIdvz0VpPVjhIPouocJeyGWL4tLPo0PC2phQljb4vXzXOSS7ed9yxdWXJwELEQHiJg OMS8xFu0p27yK3AoSQvXErhMBobctAsMg3ZpbKsNKHX+ALn0kBHkwLAoonV6ZcqbCMSv EDWx3lPhZbLmXwJttM25UQXfROqLKrkZRmzS/prghwqZWv076qzyjVPib2EvRMd+fZpj 6V6g== 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=dTXr560vxUSNToUAPpsUYL1cC/GVenTRqDjyzVI975g=; b=CUu61T1+u203iXOIQ9i3mA4h/YvTr5KaRSCwja5HYEQk5VitlZ2wTyC2soxxJaWmal 9J14t7VPd7Y2HqFhvamMjA0/xsmBU7t2R9kLyS5eU4Un8p4UJoXx1ITDBetjGG29r0FI O+Ee/TfM/xS9YP0RqRyCwgAAKnR8QMup8gPTY5IzQs33KsqD3m1uS7ZWbQHTA2ECM66Z 4KNqefyRTuyY2pW7OiIb8XJE2B/4xMrvDjuRuz8B/tfwDZFwCzKUTl+Q2hfob5l9PeHt vKqDmftX4ZKAzve/VZtn0/XdId7ubMbYoTx/xKelPExMzJw4ssXeCJQRFGw2MxA0Yg0z I2QA== 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 z2si9479569jat.35.2021.05.29.04.22.41; Sat, 29 May 2021 04:22:54 -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 S229917AbhE2LVu (ORCPT + 99 others); Sat, 29 May 2021 07:21:50 -0400 Received: from fgw20-7.mail.saunalahti.fi ([62.142.5.81]:27446 "EHLO fgw20-7.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229796AbhE2LV0 (ORCPT ); Sat, 29 May 2021 07:21:26 -0400 Received: from localhost (88-115-248-186.elisa-laajakaista.fi [88.115.248.186]) by fgw20.mail.saunalahti.fi (Halon) with ESMTP id c5aa609f-c06f-11eb-ba24-005056bd6ce9; Sat, 29 May 2021 14:19:45 +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 10/13] leds: lm3697: Make error handling more robust Date: Sat, 29 May 2021 14:19:32 +0300 Message-Id: <20210529111935.3849707-10-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 It's easy to miss necessary clean up, e.g. firmware node reference counting, during error path in ->probe(). Make it more robust by moving to a single point of return. Signed-off-by: Andy Shevchenko --- v2: don't call for fwnode put on success (Pavel) drivers/leds/leds-lm3697.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/leds/leds-lm3697.c b/drivers/leds/leds-lm3697.c index 292d64b2eeab..a8c9322558cc 100644 --- a/drivers/leds/leds-lm3697.c +++ b/drivers/leds/leds-lm3697.c @@ -226,14 +226,12 @@ static int lm3697_probe_dt(struct lm3697 *priv) ret = fwnode_property_read_u32(child, "reg", &control_bank); if (ret) { dev_err(dev, "reg property missing\n"); - fwnode_handle_put(child); goto child_out; } if (control_bank > LM3697_CONTROL_B) { dev_err(dev, "reg property is invalid\n"); ret = -EINVAL; - fwnode_handle_put(child); goto child_out; } @@ -264,7 +262,6 @@ static int lm3697_probe_dt(struct lm3697 *priv) led->num_leds); if (ret) { dev_err(dev, "led-sources property missing\n"); - fwnode_handle_put(child); goto child_out; } @@ -289,14 +286,16 @@ static int lm3697_probe_dt(struct lm3697 *priv) &init_data); if (ret) { dev_err(dev, "led register err: %d\n", ret); - fwnode_handle_put(child); goto child_out; } i++; } + return ret; + child_out: + fwnode_handle_put(child); return ret; } -- 2.31.1