From patchwork Wed Oct 30 17:10:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13856963 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 A5D10D6B6B3 for ; Wed, 30 Oct 2024 17:14:38 +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=QTtvVILI8bASQzgU7LKCLSZFap6LNc4ft0tXHklb7n4=; b=zUBJLwhdLB8b+YB9hL3EM0KTMi QDr1Fwy3CxtUDEzSej88jAuDFvrWp2qOBjvdgMyS6RZy89d/9WIRKmGy+GklzE+dWPsTrhZGTg9Rc mPfcSF5FMmVXF0OxJXb/g7DqTpsJ8Nc0dOsHa+hp+33oNbBYBYpozDxQhPR7RTn/sLMpqhsbNjAAX HQMtzLYPAvFdOIZF01ZCA7iTKchTOWJk05DkPl+JgrQWi1mSQoq5tek8nIu4WYgXUY1JZviDHXMkb POjvld+NxclBlebarqGDWndNcgQMFbMGYxoLctFlUpJ4VlIDxCr7jEv0yf2fsdZ5aYqt+17CS0jSQ JQK3q5bQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t6CH4-00000001Dw1-253O; Wed, 30 Oct 2024 17:14:26 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t6CDk-00000001D1d-2mlv for linux-arm-kernel@lists.infradead.org; Wed, 30 Oct 2024 17:11:01 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-539f4d8ef84so106774e87.0 for ; Wed, 30 Oct 2024 10:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730308258; x=1730913058; 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=QTtvVILI8bASQzgU7LKCLSZFap6LNc4ft0tXHklb7n4=; b=gxgraCWf47Kmv1e9U6vEwZ02C3iT8UP02XNtgRyGDmVwW8kPGz9cTwGh9Y7SQmtHWa 2pBojdBhnysjDO/AnaHdgb772+vauZiX5ITvBdHsuWAGTecd8QUGxf06FgJlA7CCss9s JcxwrogiGuVu0fPVDTY8oBEEnJh14mzr6jaAqDaUmJpti6A6QhyYMMhI/keytaM4/3Jb Bp7/GLq1u4342kD+1tI4MrTkPOh81fLF9GLI8nKrbDUh/664PcmLUIay6InmeN6xVTWA XJRJbT5DhJV5yi3weqt21t9zw6mcj+buXdJpCFWmOGj0wqkVoTk/TsMJDDx9jZrue2Hs G2+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730308258; x=1730913058; 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=QTtvVILI8bASQzgU7LKCLSZFap6LNc4ft0tXHklb7n4=; b=tMQNPkz1fVdm/lF8E7D8I/bPIOR9Mref2BtWJZa2IpAhG6P2DQmAU0G89vv/tn5UF4 s/tfdFA+cU9oTmJwyujaHplC0UpwtUkE6Bhn/228n+CBLkzqjv0ayaobFnvfgK1aKisM 7iAN8aaSC+gGm3eVtP7nizpr/5shno/2k4nIjGHELCsFjeYepmoyCevveLWmHJOCMsBH gvykcbXS4UmnL4th+qoiBYLlBVgL9PnXad3dkdAfBuXji7kCvKwhvR4xLv+PByJWkcfD vDX0CPrsfRfVZRvNnbifg30j8WN/NxX/3BlqCrjWHYitXXJElHWExJlEmWnr1XBhcleW hiXw== X-Gm-Message-State: AOJu0YyUWHeilUGpqxxoPGoQbb/LFR0jGPjamdEBbEFjRIUlP+0Cxjk+ UWIZHBbwl3JXTBl4xV7vGE6hsXeEdFM1sw/q0YfkknTwkU6nLbfnoMVU9w== X-Google-Smtp-Source: AGHT+IHss8st7QKvUSU+438ejEUHcCZ6cpwlHDkhixbeOiuY4PcEzYL4njnCgW9R4LX95uzpYmxAJQ== X-Received: by 2002:a05:6512:3a8a:b0:53b:4bc0:72aa with SMTP id 2adb3069b0e04-53c79e4d45emr165051e87.34.1730308257852; Wed, 30 Oct 2024 10:10:57 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-fbf3-0656-23c1-5ba1.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:fbf3:656:23c1:5ba1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd9a9faesm26828985e9.35.2024.10.30.10.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 10:10:57 -0700 (PDT) From: Javier Carrasco Date: Wed, 30 Oct 2024 18:10:44 +0100 Subject: [PATCH 1/2] drivers: soc: atmel: fix device_node release in atmel_soc_device_init() MIME-Version: 1.0 Message-Id: <20241030-soc-atmel-soc-cleanup-v1-1-32b9e0773b14@gmail.com> References: <20241030-soc-atmel-soc-cleanup-v1-0-32b9e0773b14@gmail.com> In-Reply-To: <20241030-soc-atmel-soc-cleanup-v1-0-32b9e0773b14@gmail.com> To: Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Sudeep Holla Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Javier Carrasco , stable@vger.kernel.org X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1730308255; l=1020; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=BGokR1rnVjyNDYabJSSa0k7Pn2ZZ9/4XWpf7LL38U1g=; b=EyUghQAPETz3hATWK388QYKXcL1vA578B0y0ZOrciW04D+dY7KkZeGs5utmBaPhjeySTFpXTv iBPlKCkpzAoBKbZ14G0RsDeSg5fKNv+gQVX98IvSej4UHKjivmxnCDE X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241030_101100_751093_492C4DE7 X-CRM114-Status: GOOD ( 14.17 ) 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 A device_node acquired via of_find_node_by_path() requires explicit calls to of_node_put() when it is no longer needed to avoid leaking the resource. Add the missing of_node_put() in the different execution paths. Cc: stable@vger.kernel.org Fixes: 960ddf70cc11 ("drivers: soc: atmel: Avoid calling at91_soc_init on non AT91 SoCs") Signed-off-by: Javier Carrasco --- drivers/soc/atmel/soc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/soc/atmel/soc.c b/drivers/soc/atmel/soc.c index 2a42b28931c9..64b1ad063073 100644 --- a/drivers/soc/atmel/soc.c +++ b/drivers/soc/atmel/soc.c @@ -401,10 +401,13 @@ static int __init atmel_soc_device_init(void) { struct device_node *np = of_find_node_by_path("/"); - if (!of_match_node(at91_soc_allowed_list, np)) + if (!of_match_node(at91_soc_allowed_list, np)) { + of_node_put(np); return 0; + } at91_soc_init(socs); + of_node_put(np); return 0; } From patchwork Wed Oct 30 17:10:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13856964 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 5517CD6B6B7 for ; Wed, 30 Oct 2024 17:16:24 +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=pJvO6m6VfJq7jLiXQGCAJ+rgJ6VzC5FKvl/I4BvuxQc=; b=h9oZEi2Nh3hJ6Ds+luv2q9kr1j pCiezT0Cr7c86nmFkLyBWoYrM92SZiexrLUEXevsJcP9UfgXyHxHZjzwd+GhMJKBGKEJUwJHTdjah S04SNpe7W8nISbYUQEIizp5NgR16Cnh+zNYDWb2+SpVLEQSjGLcbvxYhDFhZ2mK8xWgBRuJa9WE5x eqgs/4BGK9ZwF/t/RgK7K6YprLchOMQrrkFyjz2rklhR5Sn8kjxhpSsNhM3aF19em21d57YXiS5pA tPUlUmeOtxqLs0qPiZ4OCghNz+0XyoYNu6pXl00FHwxK3//y6HbYdqqh88AZr9qEK77AFGTfs7z4i iUvUCvAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t6CIj-00000001EQI-1Qf7; Wed, 30 Oct 2024 17:16:09 +0000 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t6CDl-00000001D1i-23c5 for linux-arm-kernel@lists.infradead.org; Wed, 30 Oct 2024 17:11:04 +0000 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2fb51e00c05so256111fa.0 for ; Wed, 30 Oct 2024 10:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730308259; x=1730913059; 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=pJvO6m6VfJq7jLiXQGCAJ+rgJ6VzC5FKvl/I4BvuxQc=; b=SFvu5Dw7LbAZRBRrqT1yRTEe58tVkAQB4M+aqCXA3ahA9LslY3fvBn8x2AtQItEjZw gW8kvh96mmHsZnFmp60kOEhs2jiVhnnSrRZm6g+ZvpNdlOZzA40Up35kMzGvt90DAMna U0qqYSGqxeZyFBQEY1JGQ2T1zbZaZmJIQQZcijUIIORsCEOOM9czsna1n7bTs8/pErFz oyztYaSc75gfuKQ18p63xw4XAe1dwIV3U1eKqS1pT3p6Qa85I3yDx0e5brdq5I9266Hy BV+VpV/WZxOmFgC+fAdf69YvJ8bKRoaey8sIQoxDsf3YKrcyUDr4XT19UhsYCZNYwPS7 IrNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730308259; x=1730913059; 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=pJvO6m6VfJq7jLiXQGCAJ+rgJ6VzC5FKvl/I4BvuxQc=; b=fh3H/441+cRm0VemT4x/W4XgBdMIuxbbSOm7TEUgP3oFgWmZ3kslA7VWQFAeEW8LpS aoLjDFqkNS2PiAdVPBZ5qa9az6g/9a2UQTepoMCd7DfIDbVuYWw43Te3kRmp2FNgs9jQ kUYuYp4hP4cZPCsrjZ4LqUbk5pXiM9tTpjSch1q9sV/3H+i7w3+0a1Dlw4XAhMO2Dy70 30UhirL/oSpcaALNlp78iAzWj7/Ln2tRu9CaWiAotZa9fUVFWpAaobbLFSOAxQFS4Twu /6foX633nCTd9wiuHicAUy9m+iWhyN3AeE7a2yVgl2ZgS0b0dh/JzIGdbZS9bR2NGrUz nDUA== X-Gm-Message-State: AOJu0Yxos5UsEp6WAgLUJA6XQ4kcEeaFVtJEiguduGRCwOY09nljMhaC 0wbjYB9qFAr5zhzIrqNIlXg7BrbHM/QJ3i9t3a9YcHWYyP5bWOhhxFBqgg== X-Google-Smtp-Source: AGHT+IE9t0eBimyH7UiH84hK6DgH1SFcaijILVkX0wzzcYM83S6LqN3c4d1isUuteAfU8x3BfYI/tg== X-Received: by 2002:a05:651c:514:b0:2fb:5206:1675 with SMTP id 38308e7fff4ca-2fcbdff1ffdmr135616061fa.27.1730308258955; Wed, 30 Oct 2024 10:10:58 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-fbf3-0656-23c1-5ba1.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:fbf3:656:23c1:5ba1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd9a9faesm26828985e9.35.2024.10.30.10.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 10:10:58 -0700 (PDT) From: Javier Carrasco Date: Wed, 30 Oct 2024 18:10:45 +0100 Subject: [PATCH 2/2] drivers: soc: atmel: use automatic cleanup for device_node in atmel_soc_device_init() MIME-Version: 1.0 Message-Id: <20241030-soc-atmel-soc-cleanup-v1-2-32b9e0773b14@gmail.com> References: <20241030-soc-atmel-soc-cleanup-v1-0-32b9e0773b14@gmail.com> In-Reply-To: <20241030-soc-atmel-soc-cleanup-v1-0-32b9e0773b14@gmail.com> To: Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Sudeep Holla Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1730308255; l=989; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=OndDXqKtEJ3cA9GTwb1q2oE8eowa7SIjG7xCrUy6/yc=; b=4PSAgRDXw7LxIptekOdlnHv1UbgiZ5LgxiPU3wDfeyUAV/VockQb3gdRTkZabAt/nKdictWHL ZmQj0gg9UejBJkOLxrq5kpZ/MLBrGlreE1U+n05iRMIZ+vjHKy76MjC X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241030_101101_565203_EDFBEBF6 X-CRM114-Status: GOOD ( 12.20 ) 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 Switch to a more robust approach to automatically release the node when it goes out of scope, dropping the need for explicit calls to of_node_put(). Signed-off-by: Javier Carrasco --- drivers/soc/atmel/soc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/soc/atmel/soc.c b/drivers/soc/atmel/soc.c index 64b1ad063073..298b542dd1c0 100644 --- a/drivers/soc/atmel/soc.c +++ b/drivers/soc/atmel/soc.c @@ -399,15 +399,12 @@ static const struct of_device_id at91_soc_allowed_list[] __initconst = { static int __init atmel_soc_device_init(void) { - struct device_node *np = of_find_node_by_path("/"); + struct device_node *np __free(device_node) = of_find_node_by_path("/"); - if (!of_match_node(at91_soc_allowed_list, np)) { - of_node_put(np); + if (!of_match_node(at91_soc_allowed_list, np)) return 0; - } at91_soc_init(socs); - of_node_put(np); return 0; }