Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp638638lqb; Wed, 29 May 2024 06:37:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/ZiUN2+htJRjAcEAsinIns8bOrx9c/su1OZRY30Bsh9HHyEa4KAr/zUBuQc3OcBZsqlZLKB6vqU9vHcydM8qmFg0aSF40i7+aUQvOOQ== X-Google-Smtp-Source: AGHT+IFAdKxwpa5ZGHyiDkWSH3PCvbfB8MbDv2D+EavPrfnVsEGUlpV855dxG8dXaEmmFFNxo+NB X-Received: by 2002:a17:906:2ac3:b0:a59:c3a1:23f9 with SMTP id a640c23a62f3a-a642d2672bamr175940666b.7.1716989825966; Wed, 29 May 2024 06:37:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716989825; cv=pass; d=google.com; s=arc-20160816; b=HLFKPKLpBB6OtbAfn3HVJrx3Md/oso06d/zOE+/mF6GLLj2EGKETWZbREITeqSvAvW AwMWu4bTPHiMAN9SYdvmoG/xxyut8tuqhlHbJhzbfKM3xcfyO8A17Gd0EqAaiERtfi8W ji/4rvB4tp2+vBifXRpBERLenbg4R2wyJvq9XA2UodO8renWHtLDnPrTfJp5+llzHIZA HCYK5tBR1JwrXrvXaR1S24cLfEeG/j1cYQ7fkIMp5AXsk1XiFM3MLIVm1vi99IbX7kdo oAq1lOkEzKSGNiNOpCJM+WlsPU1j3iLnnEFWWAZWVUiYzEqAMRJkmF98mWNFEFvJfC8e 718A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=17nJVjtQsi1HaLyXmS0JKp1M3+HGVYcOtmNw0iUnC6M=; fh=ESHvUmayJXWg6GjDHeJmvFP/mySWdYVaT1ETec8yjCI=; b=LilJs1rnpUoA266Fp/STStYIskTTD2QDWeMcHtb+UNPIMPG6HEowwu2Br4u+iGuWne JF8ukopENV0enS02WCLgIzUwACS+c0bi3/GkMs6xGFWy6gB/DmB0Ke2mFqg08OXy0R8c LqXviR0y6dbubt/2iMjKv7Y/Q/nf/f6jhHp24RLuImRKk0kTQGRvmFXMdjlwip/VMqZS c+kG/0SFjYfIp2o7nqNQhFQV7WOYDRmrcb0XO8EfwCsjwgQX+ywb/5ADJrgCaLz0Cieq j6AvPtxUGb8pWfJFKMvZRMwC3WfdsMbngHiI3er0p/U744C5URn6KudKfd3KWt8JO1PC b79g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-194168-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194168-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6513227a18si68291366b.714.2024.05.29.06.37.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 06:37:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194168-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-194168-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194168-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 78F5B1F2417D for ; Wed, 29 May 2024 13:37:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F9A918049; Wed, 29 May 2024 13:36:42 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7E9B013ADA for ; Wed, 29 May 2024 13:36:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716989801; cv=none; b=Im+lXTZlcGEiwXSoJ3ESSOrVmAHl6hfaFAYSnt+zlixKOX1o7pvtNiDWnlp2eGLkqLhpdRWy2eiqM96XpO6BErtgz4/s+xdh5JzuwiZGYUzQp1pn0o+YokNQ2XfOYZb8agrgmycUydHtSjjEl/wBretErV5ORl8iv5einrXhGDY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716989801; c=relaxed/simple; bh=o+zJGzqtKdmET2MPzNUDK3LtL/wyPC8NNUFalrWeqYM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=UnpHaPnA86U8mzm/gS/5Pjf/d4nwFryTg8mmvNwBfqZ9nF5sEjIrqf38fP40BmNX+671FHP2V4vBBydv6QhVKj2hF9HF3/u2gpTUax4TgresDjDCjMsCJq7CLKSEec87nXMRhzF+9XVL3Pbr89wb708nQhPxMArrNSChuSxY2LE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C09F9339; Wed, 29 May 2024 06:37:02 -0700 (PDT) Received: from e127643.broadband (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 14A563F792; Wed, 29 May 2024 06:36:36 -0700 (PDT) From: James Clark To: coresight@lists.linaro.org, suzuki.poulose@arm.com Cc: laurent.pinchart@ideasonboard.com, James Clark , Mike Leach , Alexander Shishkin , Mathieu Poirier , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] coresight: Fix ref leak when of_coresight_parse_endpoint() fails Date: Wed, 29 May 2024 14:36:26 +0100 Message-Id: <20240529133626.90080-1-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit of_graph_get_next_endpoint() releases the reference to the previous endpoint on each iteration, but when parsing fails the loop exits early meaning the last reference is never dropped. Fix it by dropping the refcount in the exit condition. Fixes: d375b356e687 ("coresight: Fix support for sparsely populated ports") Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-platform.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index 9d550f5697fa..57a009552cc5 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -297,8 +297,10 @@ static int of_get_coresight_platform_data(struct device *dev, continue; ret = of_coresight_parse_endpoint(dev, ep, pdata); - if (ret) + if (ret) { + of_node_put(ep); return ret; + } } return 0; -- 2.34.1