Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp62888pxj; Mon, 17 May 2021 21:01:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtCYdle1qmnF++dopmADje8t8kQ925viXVm9wWsiHvcM7VIQTIBlufUJiYBjFCrVLuTB7I X-Received: by 2002:a17:906:26ce:: with SMTP id u14mr3805688ejc.187.1621310460847; Mon, 17 May 2021 21:01:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621310460; cv=none; d=google.com; s=arc-20160816; b=tPQJOWFlGv95o0ktdJB30PxTB2XRUhWPRLyhxFUtLu0QAAObYqgDCV/ThVsbdo4Not uAAF1h68oV0Wfz5Xzj2wJclqZPGAyJ2Bgbbw8t41SGu2kMdfhR5ZGl0hCiFeT2j2TYPc tZW18W3n7+4enXz8kfdUPi6ZrC1Qek1dYmL1Bw6UdOVS9ynLSL409XUT1CF7GkhSaCwB XsBfKKxBdZAF3XxZNn4UeY6XQIoBW3fiAgccfSO+rKJUcG+kuUe7SzKUqrnqc2OXUqjI yHXrXHLLQw+PE6YNEVBhNEaBMaWhr+7VA+34YLRWhlMwohK0r+KRxLuoPNK4rhDRzPsy iThA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LnspeU662S1BHYfMyVKsw62A20IEoQ4xAfnk9pI5zpY=; b=yhWXsaVKfFmVhNFLaKkZk74rV+eS31ibZPFgI73xGVL/4VIuzt9NJOcIH8a6rQWu4d oiYLiEEDTYhkwxuLQCdpGrMzUDxmuEfzDOOk4GmyzHuEa3CRw4bbp+IqPiJHhezgYr0R YbXKu7vENF7ttYabD9UGBPBJo+KWde3Yyivb2iSzqwNTHKUru5P1HcV6YrYUXhN1Czdt rNncXGuZNirTzGMEumHH0zgJUByFYvBgnoU8jvyFmr3v/6wxRy8kFxKd/JBc5bWdTejA 4wPviVl4e2ih9qCgmR/eHH8XeUasVVcCDKSpwRV8vPmVVyCdQgYYVsmDl+YlrojmGgbg HV+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="oNsvtJ/7"; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d4si16522846ejz.692.2021.05.17.21.00.36; Mon, 17 May 2021 21:01:00 -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=@linuxfoundation.org header.s=korg header.b="oNsvtJ/7"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240952AbhEQOls (ORCPT + 99 others); Mon, 17 May 2021 10:41:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:34328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240906AbhEQOf0 (ORCPT ); Mon, 17 May 2021 10:35:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 831F46192F; Mon, 17 May 2021 14:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261034; bh=Z+su00VV6BzT4yB/RcshKmukqgCEF2W7XMrUIcaYdq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oNsvtJ/7hNutUb8pYlILiav7I7w1+MAqNSjSNTkaHfFlWL9TLGoeFvGQwH7bpC53z 8KLvkkTYG/K6O+l0JiKlM2W4jHPX1beWzDansos58efLmr7SoH8fWOQ/lFet8o254P pea7DFl/4OgAQk97RyPo0SJILQFohkwEHn6OGJ3Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexandru Tachici , Andy Shevchenko , Guenter Roeck , Sasha Levin Subject: [PATCH 5.12 294/363] hwmon: (ltc2992) Put fwnode in error case during ->probe() Date: Mon, 17 May 2021 16:02:40 +0200 Message-Id: <20210517140312.535276129@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Shevchenko [ Upstream commit 8370e5b093080c03cf89f7ebf0bef6984545429e ] In each iteration fwnode_for_each_available_child_node() bumps a reference counting of a loop variable followed by dropping in on a next iteration, Since in error case the loop is broken, we have to drop a reference count by ourselves. Do it for port_fwnode in error case during ->probe(). Fixes: b0bd407e94b0 ("hwmon: (ltc2992) Add support") Cc: Alexandru Tachici Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210510100136.3303142-1-andy.shevchenko@gmail.com Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/ltc2992.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/ltc2992.c b/drivers/hwmon/ltc2992.c index 4382105bf142..2a4bed0ab226 100644 --- a/drivers/hwmon/ltc2992.c +++ b/drivers/hwmon/ltc2992.c @@ -900,11 +900,15 @@ static int ltc2992_parse_dt(struct ltc2992_state *st) fwnode_for_each_available_child_node(fwnode, child) { ret = fwnode_property_read_u32(child, "reg", &addr); - if (ret < 0) + if (ret < 0) { + fwnode_handle_put(child); return ret; + } - if (addr > 1) + if (addr > 1) { + fwnode_handle_put(child); return -EINVAL; + } ret = fwnode_property_read_u32(child, "shunt-resistor-micro-ohms", &val); if (!ret) -- 2.30.2