From patchwork Tue Feb 20 11:50:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Griffin X-Patchwork-Id: 13563929 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87E33C54787 for ; Tue, 20 Feb 2024 11:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tMyphh1z+rHukgZ8fUqac1sMmwzOz4Q7ggvdopP8RU8=; b=Oh7XhK7V8iUeSY zr3V3Aw0mK8f6HAnr50VCKy5ulYs3iHcHDT7TS6jKW1y8XcdEqhBpcj9+m4Vr8zEEySkP9CvaUwmd 0i4Xo5Rslr9Jz2pkVbnS1tu+7TNjUBONNnSYXgWFOpc/AseBGlmH6v5wD10XjUhqJY6I9g5Iyy4x8 42V1yaJzarxpOKvm/PkiWIPpwcSU41sQmXAW3HDZWZb49Gt6U9aELWDwKAAjqXeKORwiwE641DRAf 8NZg03VUzqu7jEp+tfwn633Xf48bg1lRC68PABcC1igAujeKUPc1/F7Xi+YMt51itQTTZptJjEWor tHjs6wVRSA5ChduPBfPw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcOdq-0000000EWnr-4C5L; Tue, 20 Feb 2024 11:50:31 +0000 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rcOdi-0000000EWit-0cIH for linux-arm-kernel@lists.infradead.org; Tue, 20 Feb 2024 11:50:23 +0000 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-563c0f13cabso6516934a12.3 for ; Tue, 20 Feb 2024 03:50:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708429820; x=1709034620; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NLPhn5F1IILXAvLH2tiC+iCBpGghWpYxEC9f2Dxu3S0=; b=CrRfh/cH+koKt6s4UfQsIW6ogIdlkNcbmDUCxxoVgRYGxmNawVSsflpcA14ergosvv O5ZV2p5d9Z9TAbxi7LlqIKJ6NbOUEq0z5+3RPRZDVhjWBxgKZ/oOgbrajsblfkdqUDTp e3ybREopQb17l/bLsGjWNOfhxJ7w3aQ6kvYRpAaf7XHbjbo1N1HWq7BT75Qn0b9DPa3m aB7hk1y+uga8xg+/zlv+EdLMLYNksv/QauKCgmeX1tiu0vgRgkWfLRqcJ7kbK9NeiWKo fgXS1NPVNf/CJDzFtL8MAkDmFuQ30HqpLTkj1pOY51wgxCeEnUZKwxUTt1KdgfhYRbPg UlxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708429820; x=1709034620; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NLPhn5F1IILXAvLH2tiC+iCBpGghWpYxEC9f2Dxu3S0=; b=NFXeYwEtFVY52umZJHy2dXsrAr5raU6X9W6CiSrDDOfA+qUKeYLitzyr4RwO9jtWPQ HabTZGSGrxvm0ZU61IR23NJ7rrhdxehOxymP1lt/PQ+PGFCnMXc+DoCXRa9LE4opoN3I h5LD1RSFCYswbCrnEbHVFpt4Rgdo8VZ7zn7SYWGF5uoIYnC2+oaEs2AQX61Sg77+ZAez ubjdGodwU9eizW1iid+8HI8zaQQY9u7SjnTlpRdI4qlib0JKVa8rdIaQ1xVO8XzRRCTJ UIOJTR105R3ZTrd1+G02nKWPiokwDsNRyYjDE6jry4K+DU3Uo2HKKjUqSFALGvYEyMOL 1xHA== X-Forwarded-Encrypted: i=1; AJvYcCX3J8Zuwg+TjnBzDvqqxHdhh3AAWaKZerIH3jbZiA4GgUTblZHMOu31CerH5NdDZAIKkr3rgYLJ1+2PX+g+jqP8b6lF1Yb2MLbPeByWk1R/+irPQbA= X-Gm-Message-State: AOJu0YwLN+gWeqTyp4iTyBsq7sDY7DpSaJWzhHC2wo9JNhMnub4SiUfr u0QOS7BxtMZvP0ieOSEIsT0QFg+KN/YEDvsdwezgt+4VjpIKXZ3F+5BW4Ktuwaw= X-Google-Smtp-Source: AGHT+IEV2SGfyL00WThZuIpxrCxkMf+jEK6pTjTLPCvz1phzExr0o/5hORq48Qd+ppjGItJ2AO/NBA== X-Received: by 2002:a05:6402:1b1a:b0:55f:6a87:8033 with SMTP id by26-20020a0564021b1a00b0055f6a878033mr12182959edb.31.1708429820121; Tue, 20 Feb 2024 03:50:20 -0800 (PST) Received: from gpeter-l.lan (host-92-18-74-232.as13285.net. [92.18.74.232]) by smtp.gmail.com with ESMTPSA id u16-20020aa7db90000000b005645c4af6c7sm2317832edt.13.2024.02.20.03.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 03:50:19 -0800 (PST) From: Peter Griffin To: arnd@arndb.de, lee@kernel.org, thor.thayer@linux.intel.com Cc: kernel-team@android.com, krzysztof.kozlowski@linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, pankaj.dubey@samsung.com, tudor.ambarus@linaro.org, andre.draszik@linaro.org, saravanak@google.com, willmcvicker@google.com, Peter Griffin Subject: [PATCH 3/3] mfd: altera-sysmgr: call of_node_put() only when of_parse_phandle() takes a ref Date: Tue, 20 Feb 2024 11:50:12 +0000 Message-ID: <20240220115012.471689-4-peter.griffin@linaro.org> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog In-Reply-To: <20240220115012.471689-1-peter.griffin@linaro.org> References: <20240220115012.471689-1-peter.griffin@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240220_035022_265161_70088CB7 X-CRM114-Status: GOOD ( 13.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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 0e52bd2ebd74..fb5f988e61f3 100644 --- a/drivers/mfd/altera-sysmgr.c +++ b/drivers/mfd/altera-sysmgr.c @@ -109,7 +109,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);