From patchwork Wed Oct 30 23:25:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13857294 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DBD71E3DDD; Wed, 30 Oct 2024 23:26:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730330767; cv=none; b=SbHQFOP0j4xyWh91AvoljNQdiY5JWFBrA7HN+FRlmYI8I16dbjkLj4DqCXkzGeQcbwRPB/5FXiqlvf0o22pV8xRf3c5Q1R+Ph8nEQxJqJrTBRwx8HESfTxE6shYIUnkq80v3KcydNBw2YdC3u81FvgoNYBOq3FtQD19VkasXwwQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730330767; c=relaxed/simple; bh=MCSmuEk4fzdFG0/fr1cFdVYK9Z+TAFWrcnZ1tpPDXpk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pC8707TFtlUuQH4NpwwfcR2RbH5H7VYPlQqd3DgOBzLyp7uLpUP7MHQ6w/QgqOssoU8AUjMDVfaFdSxS49uswf9vfae6oJUAv3+ctLgZhEbXbB/EFDHcv/jBwWznUyM5OBXCizXAEB7fRz1fn9GuGfzp1zZ5Tl6NCjEVb9q8la0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Uwmhe9H7; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Uwmhe9H7" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4316e9f4a40so2833895e9.2; Wed, 30 Oct 2024 16:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730330763; x=1730935563; darn=vger.kernel.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=YXareB8gROQQMlffCs1rrGjwMItPDqgeuEz/CInJUko=; b=Uwmhe9H75wcbjFTBguKdJI4+m1/n2j8YiuehDANeY2euDGSOlgfEfuWFfUXqCW8SuM Zo6Rfvh8VzDjOEBaRKUxEAf939CN9SV6pP64sNO223rGDjLimHFBBA2tJSP9Q3T2/PRF BD9T8xKulgxH5hoS0zpGwpPg1YuHYY3gAufhzEc6i9/fUTxu+sFTO6+AsfHboEITvryK Zq/vG/F/C+R5RekeMgqZmIxzOo8ubY5qOPJ/V0KqXJG5EeWlwYy9PdXCCrOVjWQOg+cm MGGsoaX9o9GYG/egNyZkm8t0jCDSw1KkYEAmGZ9mdetwg6CfFZT3gQLkvQA19HqhOp4B rRvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730330763; x=1730935563; 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=YXareB8gROQQMlffCs1rrGjwMItPDqgeuEz/CInJUko=; b=xKnkUTqVhvPbHMxFRegSL2c5/FuZTka5yrtckWc3gkKlwcuvTyM+i1NQFwha4OYQ0o TEAGyNdKUYy0aKZHrR0FojioEwh/sIGVQeSohbIa1UEbiaNwWURxH0NgzBZfPEnYiQp+ WqaRp0M4vjPgiZsJnZdP18/cg6aZ2ioLIqmzV6SXWEFxvT8h8zUPBcYwC7uRIwVZBBjy LUgOaROwunamqFJcaYg0G8EQT1VunBPoo0JJtRZxVk1dorULblKGsmvEQfcThat/ZFRi 4bAk8JhvGu4phxLXs2T+cE+Pk+k7sEzKZ0hbOEOkl4CBYagw1uJV2M9QATnq+V0B1yEM XsRg== X-Forwarded-Encrypted: i=1; AJvYcCUBo7vcmCd0b8flzei7vxzUSlHoegSAEqjcke4bbhQ2hZNVc7r1faMR/uaVosbkLuWJ9euWwS1wzG4=@vger.kernel.org, AJvYcCVBFIg07YPQDaQ46SXYow2GBVG//6ZvZOwpXY+TVniwv9Bk7gAusZyEBlsPwHw7Uze+bPaouOjH5DdUsy46@vger.kernel.org, AJvYcCWSaSPxkThcVVIyii1sETNjoqgzOzhwgKyz1hTKwXyis46ZCAvj67uPOzv4ASXjjP2yZSFVu1Mb@vger.kernel.org X-Gm-Message-State: AOJu0YwQnynutvPZMD2L3CSyoIR5ZA03QVvh80HaOJZHMzqpz2bdVcFU WbxpKd1K5+BUffyUj2HGMMIMfOrOLiUzjHAgWPB8BfWMLz/Lk/5UoLco7BuZ X-Google-Smtp-Source: AGHT+IErYXwmvTXC4B/LlkFNOwelPHOAQu/z3+IlX6nrzedWsMDSREVMl7lNnuvijDNJL8RQ7rVv0A== X-Received: by 2002:a05:600c:4e8b:b0:431:40ca:ce44 with SMTP id 5b1f17b1804b1-4319ad34a44mr140228715e9.30.1730330762889; Wed, 30 Oct 2024 16:26:02 -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-431bd947b2bsm35338395e9.25.2024.10.30.16.26.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 16:26:02 -0700 (PDT) From: Javier Carrasco Date: Thu, 31 Oct 2024 00:25:56 +0100 Subject: [PATCH 1/2] clk: renesas: cpg-mssr: fix 'soc' node handling in cpg_mssr_reserved_init() Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241031-clk-renesas-cpg-mssr-cleanup-v1-1-628274ecbfcb@gmail.com> References: <20241031-clk-renesas-cpg-mssr-cleanup-v1-0-628274ecbfcb@gmail.com> In-Reply-To: <20241031-clk-renesas-cpg-mssr-cleanup-v1-0-628274ecbfcb@gmail.com> To: Geert Uytterhoeven , Michael Turquette , Stephen Boyd , Kuninori Morimoto Cc: linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.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=1730330758; l=1293; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=MCSmuEk4fzdFG0/fr1cFdVYK9Z+TAFWrcnZ1tpPDXpk=; b=dYQclrbQ6H4UBFuyauAWPvlbRxHC+/vw4xnNoQv4B1MEy3O5vAlEqNTAplUFFEYly85NckWtr eAkb1l8Zh8wDijCzGYKPBD99mT0KK+N/emSelbK/2tW9oNsrwhbd2wZ X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= A device_node reference obtained via of_find_node_by_path() requires explicit calls to of_node_put() after it is no longer required to avoid leaking the resource. Add the missing calls to of_node_put(soc) in all execution paths when 'soc' is no longer required (one error path, and the success path). Cc: stable@vger.kernel.org Fixes: 6aa175476490 ("clk: renesas: cpg-mssr: Ignore all clocks assigned to non-Linux system") Signed-off-by: Javier Carrasco --- drivers/clk/renesas/renesas-cpg-mssr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/clk/renesas/renesas-cpg-mssr.c b/drivers/clk/renesas/renesas-cpg-mssr.c index 79e7a90c3b1b..5dc89b1009fe 100644 --- a/drivers/clk/renesas/renesas-cpg-mssr.c +++ b/drivers/clk/renesas/renesas-cpg-mssr.c @@ -1022,6 +1022,7 @@ static int __init cpg_mssr_reserved_init(struct cpg_mssr_priv *priv, ids = krealloc_array(ids, (num + 1), sizeof(*ids), GFP_KERNEL); if (!ids) { + of_node_put(soc); of_node_put(it.node); return -ENOMEM; } @@ -1036,6 +1037,7 @@ static int __init cpg_mssr_reserved_init(struct cpg_mssr_priv *priv, num++; } } + of_node_put(soc); priv->num_reserved_ids = num; priv->reserved_ids = ids; From patchwork Wed Oct 30 23:25:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13857295 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A04C921745E; Wed, 30 Oct 2024 23:26:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730330768; cv=none; b=hiDZ7jrVyHiDK3NPfdwVDuGlojJG+F3R76K7/VN1UUNk2fPG540l2NRYwge18pD8bzZket49n2vGGpc3dLJneCq7dp408dI76VsWJseZYema5Dnaf8z+UODz9eoczavdQFXK9mCnVuT+xIpxsHIw/0aiTCqVCt9XkcXJ1YCy9yk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730330768; c=relaxed/simple; bh=qG6IB3tD6+yPM/lumoXSZZ9FRa0pFVxRt2KJfcdlqPM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LZwgXjaOOv3e1t2isZOrQ5kxDzehFK5pTjm/1UMYO8colBDTZLMBbS/73wlgqY1cjFKrgei7UmBoWnU1tH9dIOYrqQsmXHmKKN0rtb7Iafpied7Up/7DmycKA91HrB2Cxf9vA/1LC81a2yIKAG+aSgPkfOlcq6rfdllqm6G2n0w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RP+yqwF/; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RP+yqwF/" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4315eac969aso2069495e9.1; Wed, 30 Oct 2024 16:26:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730330764; x=1730935564; darn=vger.kernel.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=etFHZ0EqGWLVKcZ/IRxxgETEj6o4J8B9iZYvV9e7Iv8=; b=RP+yqwF/4kICNBlmxSDI31PsnAN/TNgg7iPaVRLoA6TlMDh1SYwE2MWvny7P3IpqEj OOR9s4B3ztEPXRlpsxRE4KztJtPnCsk+ZYwFQQpoBe+LgKwCfZw8A89LpsN43DZIjpYs lR55LI527jzRs4ebd7pqDbM3PTC5EFaFxgXE6B+ZljPOrS7rgcYK+QZTiQRzMscRTKLL zMnZwU/m/tc5ZL1pGyjgwiknVpE3tGsVd98Df+wZAfXRHO8xLMuuUADz10QkEA/Q3xFu 4+Evn/uin7cNPGcfHOGdKjpWVt7ZscOmEi0Qvbsgj8aMBNf3VdkSLToeEYtrQ88O/SC5 T/yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730330764; x=1730935564; 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=etFHZ0EqGWLVKcZ/IRxxgETEj6o4J8B9iZYvV9e7Iv8=; b=TJf+ivEzdf6mHndiqM8v75Khfwf6KsTOHBy8Bh/lAd+x8WFb2Xsz1CKjctapsBQqBI fcm5qpGRwwTCPFGJV1IjYpGpBpeLU/ekQM2azoeFPV5Nnv9qxTElO72848gTJkWiTsFN lyhNGEWj4ZZfiHDug5UL2uxbggjio5aqw/IGof+y3cncgUlxQkIz/Q1HMnGdKnVoZhSJ yMh5J79oqhnRMWbgHacAPd+mIQDcahC1V6I0iMO96NqgEknk7ynJ5fC71Os8s6xAD6Vd ELXIbU2n0DsoP83F8UiSBdMLdRFWyInj2uXnGhhovw8RZmATa//2Gxb9htgC6cTh10ID lZFw== X-Forwarded-Encrypted: i=1; AJvYcCUg9yYlPxGWRNj9U8tEYpQUIQfm299rS8dBrbaxilF21n6gA75B+TJuIhyxD2o+gzn2QakICSenuGQ=@vger.kernel.org, AJvYcCXvDWBscI/umiId/GOhjNSHXj1MfaTY/sOrJnQc35/DNBHetBFZw5oabSpN5YPWpMAGuT0g6ZI7sSUZJYjm@vger.kernel.org X-Gm-Message-State: AOJu0YwUPPXlTt2evNCpXQHvLAHJiDhXU00IkMvqgR6aJCnrTQOqb/b0 duAzo6N76CM45MompVq7raYZfvbx9Ry62hXQYsE7kKEmR1uOecmB/h1oehiX X-Google-Smtp-Source: AGHT+IHkWyosrXnzVUyRsA+eYkVHkUHdz/o5cdlWAuNhG2zBqgplMrWgOLtyxRKXBztlD+ybaW8eOQ== X-Received: by 2002:a05:600c:45cf:b0:42c:b54c:a6d7 with SMTP id 5b1f17b1804b1-4327dbcb535mr2530365e9.14.1730330764290; Wed, 30 Oct 2024 16:26:04 -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-431bd947b2bsm35338395e9.25.2024.10.30.16.26.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 16:26:03 -0700 (PDT) From: Javier Carrasco Date: Thu, 31 Oct 2024 00:25:57 +0100 Subject: [PATCH 2/2] clk: renesas: cpg-mssr: automate 'soc' node release in cpg_mssr_reserved_init() Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241031-clk-renesas-cpg-mssr-cleanup-v1-2-628274ecbfcb@gmail.com> References: <20241031-clk-renesas-cpg-mssr-cleanup-v1-0-628274ecbfcb@gmail.com> In-Reply-To: <20241031-clk-renesas-cpg-mssr-cleanup-v1-0-628274ecbfcb@gmail.com> To: Geert Uytterhoeven , Michael Turquette , Stephen Boyd , Kuninori Morimoto Cc: linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1730330758; l=1461; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=qG6IB3tD6+yPM/lumoXSZZ9FRa0pFVxRt2KJfcdlqPM=; b=iiREKCHRI7wAcjIwWXi2Ozabkvpi9cjg2JuT0ONzaOGUI3UjRxWWL2+aAvmaJ6YSzts7+ZrsX Mz1KQA67g81BWG0ZJoYYaiZxncbA/NgZ4UsOn5OVkwgz4MHVr4ntqOv X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to a more robust approach by means of the cleanup attribute, which automates the calls to of_node_put() when 'soc' goes out of scope. Signed-off-by: Javier Carrasco --- drivers/clk/renesas/renesas-cpg-mssr.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/clk/renesas/renesas-cpg-mssr.c b/drivers/clk/renesas/renesas-cpg-mssr.c index 5dc89b1009fe..bf85501709f0 100644 --- a/drivers/clk/renesas/renesas-cpg-mssr.c +++ b/drivers/clk/renesas/renesas-cpg-mssr.c @@ -979,7 +979,7 @@ static void __init cpg_mssr_reserved_exit(struct cpg_mssr_priv *priv) static int __init cpg_mssr_reserved_init(struct cpg_mssr_priv *priv, const struct cpg_mssr_info *info) { - struct device_node *soc = of_find_node_by_path("/soc"); + struct device_node *soc __free(device_node) = of_find_node_by_path("/soc"); struct device_node *node; uint32_t args[MAX_PHANDLE_ARGS]; unsigned int *ids = NULL; @@ -1022,7 +1022,6 @@ static int __init cpg_mssr_reserved_init(struct cpg_mssr_priv *priv, ids = krealloc_array(ids, (num + 1), sizeof(*ids), GFP_KERNEL); if (!ids) { - of_node_put(soc); of_node_put(it.node); return -ENOMEM; } @@ -1037,7 +1036,6 @@ static int __init cpg_mssr_reserved_init(struct cpg_mssr_priv *priv, num++; } } - of_node_put(soc); priv->num_reserved_ids = num; priv->reserved_ids = ids;