Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2580703lqp; Mon, 25 Mar 2024 03:25:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXV5WPsSSX/e6k9z/VwnK9VabOMYsG82URpalPdBmIFVNjtcKAr5Hefk9fB14dzdNQeuVVCzVN1aObTG1Rj4B6jVPAlpI9X+xCzHVpSkA== X-Google-Smtp-Source: AGHT+IHSHFpSAJiNn+8Ef+p3h6z2t1UVgf0SY2h+2fBjSG6czCkQ4T0n8Kvt/lDzFGpbzkNiMG24 X-Received: by 2002:aa7:8edc:0:b0:6ea:acbe:5187 with SMTP id b28-20020aa78edc000000b006eaacbe5187mr2673698pfr.20.1711362325274; Mon, 25 Mar 2024 03:25:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711362325; cv=pass; d=google.com; s=arc-20160816; b=ljcfCPL4bhgxlmDdJfRGo6fXo9ndmz/IdqCgk6CUryxhrcs2nDD0WWCz0hhF8Dgw7V Pp4NjxjrWKJwXxrch/rZkhH+aFH1vdCclVBKuhIUEvhukRHEUakOv1xAJaaJ2jIFeLAy 6lv5fe04IlcTom+TPryPYrkASbnmywOPVBoX2U0m4giI7oC5KE0NSAkC4mdJEvdccHq1 mlqxreDysY28l+F9JylOz5B8Twi2gKfibSTZk8MEqbAOHDlYV6gXGt7VOZVzwnnlQq6g GCJQiHdFFbmpKEPXFFDxuypvRhCxiwtNggYtxb3CD9Y9qkRX5wrgXECuwNwXLlF3PPiG tYwg== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=OZnEDpKvjSsFeTTfcY/LIGeTwfoKBcn9I5YvTowqnXw=; fh=KXyW26nOJVhyZBrBMcColsGz6kKR7G/JY7sJfcY1W2A=; b=yvMjy0iB+PxnxQ3s5nYLGA+6hVBWuOoxxmpTGwozO6IOhbopVF25yfKG3IHY1ZPr4A pULRyzDyi2io2t7nHJvvsg+2gvzPp825vmaWqmGh1iqXpHMi8BlmRxiRuRWaruvnPkiO kTFWMU19OnIURborxZetMokG+Cu9mc/9NMsX0RA+9zZ+40Vxvp1zeNaMu2TI4LtAG74i SM/R+6pSOmWcFkr0FWlWUVCUB0iJDcz8EQRAAhXjFin4cZULsUaYs3Xj5LVwAkPZmM28 RNTqwoq4SY81LLZzUQ13jdT6Vy8jSTBd9kB+ozsRdrbyR+WSxKOWdGcjXF0TzoNwMPPT JxIA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rkJSDXcK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116189-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116189-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d12-20020a63f24c000000b005dc36761adcsi7591352pgk.175.2024.03.25.03.25.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 03:25:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116189-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rkJSDXcK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116189-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116189-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C9FE92C30E9 for ; Mon, 25 Mar 2024 10:25:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17E643B9C95; Mon, 25 Mar 2024 03:33:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rkJSDXcK" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD824284529; Sun, 24 Mar 2024 23:43:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323787; cv=none; b=isoy2EFG5gLxtme4TCK0Q/pZt22On/H9HdGzKl/XerID8ZeaftqxTrRtPZKnch2hzdhzSRnG+Ke0igSURD05y6yoU+4FuWuPjE7nsVy+h01/Ix42EckUuNQNGAyJ50oCDrkXHmS5s1IGYFF4rMaWF9MjIinafTni0M4CwxDv71E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323787; c=relaxed/simple; bh=xzg6Cl94C/B0zCZhufvQBgehOCoHAT1Tchoclmig22g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KiVkBpX1EXBCWTEhIzi7X+evtfS7uFXi7i/IMjkHVMOawzCWVChVqLf6YwT8vwjeS+m6EpLFWnLJbbjw+rLWUA8J91Qz4z8nbv4X5o1GIgJgKjEdSTIdWlIl33ooOC1L4ME2Pv+i4BZQ9Z8yty7xdREkFoaxKGL0YKo6SIFN3x8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rkJSDXcK; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFC38C43394; Sun, 24 Mar 2024 23:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323787; bh=xzg6Cl94C/B0zCZhufvQBgehOCoHAT1Tchoclmig22g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rkJSDXcKx882l53HutnOB5ctUCoHSakeLrW/YoHfIZyEx1KugVS1DGBswEVWBsL2+ QOAsg8DE/3h9xWapfYxwAyJ28GDYJKN343zmVrK1kALDeX0/PQg0O8gYLQCMzz0lPh 1niPhSHGjal77evERboPchm1tpOB1HcFrsgCVzbcF3Son+yoYbnyU2CG676nl8raGB 8/EOE6dRmKlI0eyW2CM6rndBjZ36Fv0JsbAO2bfhAXi00l8DdvmAUEKQxw9u5J/ppT 7w6DOFrqM6u5g1U/aQN2lwhJDbEYTyZa9YWKke6PZjPMUjmEYylUlKGyCgupUZ6HpI B5dHcKA6wrW0g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Peter Griffin , Lee Jones , Sasha Levin Subject: [PATCH 5.10 164/238] mfd: altera-sysmgr: Call of_node_put() only when of_parse_phandle() takes a ref Date: Sun, 24 Mar 2024 19:39:12 -0400 Message-ID: <20240324234027.1354210-165-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324234027.1354210-1-sashal@kernel.org> References: <20240324234027.1354210-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Peter Griffin [ Upstream commit e28c28a34ee9fa2ea671a20e5e7064e6220d55e7 ] of_parse_phandle() returns a device_node with refcount incremented, which the callee needs to call of_node_put() on when done. We should only call of_node_put() when the property argument is provided though as otherwise nothing has taken a reference on the node. Fixes: f36e789a1f8d ("mfd: altera-sysmgr: Add SOCFPGA System Manager") Signed-off-by: Peter Griffin Link: https://lore.kernel.org/r/20240220115012.471689-4-peter.griffin@linaro.org Signed-off-by: Lee Jones Signed-off-by: Sasha Levin --- drivers/mfd/altera-sysmgr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/altera-sysmgr.c b/drivers/mfd/altera-sysmgr.c index 591b300d90953..59efe7d5dcaa9 100644 --- a/drivers/mfd/altera-sysmgr.c +++ b/drivers/mfd/altera-sysmgr.c @@ -110,7 +110,9 @@ struct regmap *altr_sysmgr_regmap_lookup_by_phandle(struct device_node *np, dev = driver_find_device_by_of_node(&altr_sysmgr_driver.driver, (void *)sysmgr_np); - of_node_put(sysmgr_np); + if (property) + of_node_put(sysmgr_np); + if (!dev) return ERR_PTR(-EPROBE_DEFER); -- 2.43.0