From patchwork Sun Aug 25 14:14:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13776782 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 E0AC1C5320E for ; Sun, 25 Aug 2024 14:17:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+vyI734cRrZFj0A/p/jgke1T1ninVILNTlfgxfQSwKE=; b=zpCpilrTlLl70+Mk7R5OuYqOq5 xv+yBxBCCRV9nRRxch7Ud4NSJkuIlSDP48S1kl2ga0jgRYxjWeKj3v8701IcnAHQjU0WQzLZN/iBG WOZ3hV5hVsKdPr9k5uUJupjZULkqYDEGcx/DZqm1iJMlXhqa/HPB4JptbZeOdowOjDjx5ExIROFDX naZGGUt1cZhoI1kT+AZ34MOpfdvDGHOrV8RdkDWWr4QCbLrhUHf3HGUu3g7QIxEBWq+qy2OpYWnqb Rh5kNbbFp4tYs7jU9zL7a082+M/WOFrlT8Jv9y2AzjnSwc6lT7ZLg1BxSVxMWOINbK1nJcktASMg+ C6U4/eqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE34-00000004Svh-3Svk; Sun, 25 Aug 2024 14:16:54 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siE0r-00000004SHr-09RZ for linux-arm-kernel@lists.infradead.org; Sun, 25 Aug 2024 14:14:38 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4280772333eso5433865e9.0 for ; Sun, 25 Aug 2024 07:14:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724595275; x=1725200075; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=+vyI734cRrZFj0A/p/jgke1T1ninVILNTlfgxfQSwKE=; b=uY2C2CIq+AkR79a18RDC5srSsUyZMLlyhfG2f+od0VEhn+2kfnMeYltAYwn4Fm0YDf MqUzQ4yE2ijHGWGv1/UcswFzxVVZq/JDoNNAhJmn3R7rSYZdnd8yFXjxmYMWjokpWdSg ghBXJ7FJYE+CPlO+cGPbvPUf8mvW+waouEhFDV9jJxpChKN2Mx1rwcQ6apFZwagyh53T K6auAJyiwZl01zzBe8EqOKgu4gmm/7m0GrSF3J8YwocnACBRYAzN3yFriuXJQta38GAC XtDCF6F8ieByqgf0poJPWbcbDKEzv/AmGa8rKf6aqKLlzmpxH4adUMc4xaD8bNOxl3gM VnrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724595275; x=1725200075; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+vyI734cRrZFj0A/p/jgke1T1ninVILNTlfgxfQSwKE=; b=YFWFzrMAoFWdM1sI9RTtrKabIiGOqjUXceX5aosmg+7zU0U4aZuK7iyDqkAdxhPMUz kVuRaZwpzu1ETMUH5qpjMSV6oMcQvtbfqjfoo7JRNSoRWYu9RtCShJAKY2vC9XvOYpkW /uqsnG73/S/pVTkDK+nW+6TXEjV0dtZ8DP8J0FCqOkiXtwBVqzBafcuJvaqgWC+Kl6ee 4WElrn/T8zoEZ/aap8DCune94zDKWdzwUh7Vptos5VciY7ESmv7k2oQ+h5W1Pu5dW+Vx PHbakZkTbgnKFJTxdM2lBQKzMtId+Xr8NxoBRvZSplwzVbTrUaT70U9mrhxeYMWK4O+k 1q4w== X-Forwarded-Encrypted: i=1; AJvYcCURaDK6tiRZdLe9t+gf/o68tWIG5qP61RRjuFg1qt4sbUQ2Tw9KTx+k2AJwlMinjSeoNbPMvyz1CD32gJhO7ARc@lists.infradead.org X-Gm-Message-State: AOJu0YwbgOftBMYYEMRtIMNmS7kYE7n0hJW7ZD2pSv/rBvP2O+nZkjp/ ME25DFz6OZ1+Uo646s45Mpk53+z1B/Z761788KCklKJlyQ4GkYGcGlykI4c6s1E= X-Google-Smtp-Source: AGHT+IFak5e9TgxMwRV1VQC3TmD/nC7hYru8uGqId4jYQGfP92V0mB5tath7X71OxrZX1Y6HIUhsVA== X-Received: by 2002:a05:600c:1d25:b0:426:6ecc:e5c4 with SMTP id 5b1f17b1804b1-42acca0c727mr34083495e9.4.1724595275253; Sun, 25 Aug 2024 07:14:35 -0700 (PDT) Received: from [127.0.1.1] ([178.197.222.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ac5162347sm122556045e9.23.2024.08.25.07.14.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Aug 2024 07:14:34 -0700 (PDT) From: Krzysztof Kozlowski Date: Sun, 25 Aug 2024 16:14:25 +0200 Subject: [PATCH 2/5] reset: k210: fix OF node leak in probe() error path MIME-Version: 1.0 Message-Id: <20240825-reset-cleanup-scoped-v1-2-03f6d834f8c0@linaro.org> References: <20240825-reset-cleanup-scoped-v1-0-03f6d834f8c0@linaro.org> In-Reply-To: <20240825-reset-cleanup-scoped-v1-0-03f6d834f8c0@linaro.org> To: Philipp Zabel , Antoine Tenart , Sebastian Hesselbarth , Damien Le Moal , Palmer Dabbelt , Vladimir Zapolskiy Cc: linux-kernel@vger.kernel.org, Damien Le Moal , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1185; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=9pgusit1pxrr+A2/sS7UfW0KAIyXH2HmTDW6oahLzho=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmyzxD9ZG4S/H4bpvV+Ch6/rnPSqPk9mJsU/Jxb DPFQLvB6+KJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZss8QwAKCRDBN2bmhouD 19lyD/4x8fa4AOkKyveVLnoZhsiOq4/EM63MPkrJMxfB9Vfm/yTnK2uzctxkuWPgDgB076mY76k SaMnFfbFkK8VdlwXcAX/zFm0PBTyRXcbKk7Nv4u01b8rHPx9IAHCFOM8hIwGIa03i6XNmsL5Uko t42t2QmGdu6UFGT4kC9GKB5YbpDuZVYys8UZdPTYbwFScrCa3qRrMkZFZJZ8KP2YPGNtRR/F/Ua NqmT68ych37x5XciGnCF23o31YCm6nU5COwcDG6I/N7hWjqMt6f8ur/bRKEJeV/BJWFlK+Y2VHj 2zhkkrX7jC/eVXDm8L/zrU+aIn68h7lrDNgOtp53fekgqoPoQ6VXqmXGzYpChSl8atweHp1gDBr Q0/uc0DWw/Nheal0uryPSodVR2zQ1iqMoCxEPIa/wPHNqOcPOxjFC4OLs2tBViG6jaTrsWuRQBm zpVBbKkvEGSsf9sPZoNLWnyG6k9DnsXaaNoJPRC6EFXmpGJPnCIFAFW1BLmK02AWvLJ1IfZmIv6 Dem+z3xlw1HPDUIc1VjoTAXgLqUVqUFiSWXjd4jYqUtCtbvsNqp8+3iMCsvZAKJuK7RMKQGLwOs l3/2GQjQD7VfbOVodIn3WKUknAfKn67Gdhj0ML4V9Fk3gIyBj93OX8kSoSyTxq2vYb91N1LAfbb 6ZR51YIOEl0TDoA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240825_071437_114231_93E681B4 X-CRM114-Status: GOOD ( 13.39 ) 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 Driver is leaking OF node reference on memory allocation failure. Acquire the OF node reference after memory allocation to fix this and keep it simple. Fixes: 5a2308da9f60 ("riscv: Add Canaan Kendryte K210 reset controller") Signed-off-by: Krzysztof Kozlowski Reviewed-by: Damien Le Moal --- drivers/reset/reset-k210.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/reset/reset-k210.c b/drivers/reset/reset-k210.c index b62a2fd44e4e..e77e4cca377d 100644 --- a/drivers/reset/reset-k210.c +++ b/drivers/reset/reset-k210.c @@ -90,7 +90,7 @@ static const struct reset_control_ops k210_rst_ops = { static int k210_rst_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *parent_np = of_get_parent(dev->of_node); + struct device_node *parent_np; struct k210_rst *ksr; dev_info(dev, "K210 reset controller\n"); @@ -99,6 +99,7 @@ static int k210_rst_probe(struct platform_device *pdev) if (!ksr) return -ENOMEM; + parent_np = of_get_parent(dev->of_node); ksr->map = syscon_node_to_regmap(parent_np); of_node_put(parent_np); if (IS_ERR(ksr->map))