From nobody Mon Feb 9 03:43:09 2026 Received: from pv50p00im-zteg10011401.me.com (pv50p00im-zteg10011401.me.com [17.58.6.41]) (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 1EB16218ACF for ; Thu, 9 Jan 2025 13:28:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429289; cv=none; b=l2GHuCUG7vNnlbNF9kxe6VpsgRpV0B9bULYyGE8wZGQQpyPBiRFtJBMEsCBxWkMZ1Pz6ILYYTLTQYjUS9jwgh+2e1J/AASx35xeN9i7IADts8qzC9CmwMSgq+++nHAg1UIUCCOrjzxp5mbRwvKCSOwoH/mKmJ3NKxnF4DSooLT4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429289; c=relaxed/simple; bh=F7VAazrVJ3p7QlbMjlcZ0vd+3ltdvGaw1yJxrtSHdRM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FQE1xZyDOW6sp9KK3PtqPaRLpZsz3HNx/4l6xDuD4nMBqRVVTT0oMnkCg66yaHxbzJSSTXBY53HbX9PT7ovh96SGBSj4LZPxpkuM78ojoOYHRfhwm4IaxKq7ZGlQez1an/UO74YcuPfeSLkzHU/WqYRGd8jp1yJDU/Fv2z94Sbs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=n0sunCGs; arc=none smtp.client-ip=17.58.6.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="n0sunCGs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1736429287; bh=1qAwxeqobZh1wxnxdDloQZW9DdsopGVNulsZoYj9sn8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=n0sunCGsVChe+sX6BG5xfiYqow+ESjbPYVZs3rJRlcit5QFq5wj1dk32kSFyHQNbV QfAXv8JCmNV/1vzYv5gxJJNf5lU8pXmIzes4cCM4QDfzHkMp+TBue4jlldKknFUWto j5gQocd4ODb7Z3WyPBUn1tCIAFmwVJw5+rAFBKtTjs7Kp+hfsnSLvksxAzjI3wIk+C 4dYy86UkreIAzR3iIiRKOPt3Fawk6mheEQWQKs8LCEOzATjndXxwBaKnYbbCDPwo4W YUl91dxLl4fY4wV4IdzZpAorQyuhm/tQdGQKMQgDAjujbJClNdOeU+r9r7zbFIcWtM W4SfVRnviyxOg== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10011401.me.com (Postfix) with ESMTPSA id 57F1C34BAA4B; Thu, 9 Jan 2025 13:28:02 +0000 (UTC) From: Zijun Hu Date: Thu, 09 Jan 2025 21:26:52 +0800 Subject: [PATCH v4 01/14] of: Correct child specifier used as input of the 2nd nexus node Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250109-of_core_fix-v4-1-db8a72415b8c@quicinc.com> References: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> In-Reply-To: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> To: Rob Herring , Saravana Kannan , Maxime Ripard , Robin Murphy , Grant Likely , Marc Zyngier , Andreas Herrmann , Marek Szyprowski , Catalin Marinas , Mike Rapoport , Oreoluwa Babatunde Cc: Zijun Hu , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu , stable@vger.kernel.org X-Mailer: b4 0.14.2 X-Proofpoint-GUID: otQngs-fv2H_5hbv8UXVR-1zY8u42B3r X-Proofpoint-ORIG-GUID: otQngs-fv2H_5hbv8UXVR-1zY8u42B3r X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-09_05,2025-01-09_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2501090108 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu API of_parse_phandle_with_args_map() will use wrong input for nexus node Nexus_2 as shown below: Node_1 Nexus_1 Nexus_2 &Nexus_1,arg_1 -> arg_1,&Nexus_2,arg_2' -> &Nexus_2,arg_2 -> arg_2,... map-pass-thru=3D<...> Nexus_1's output arg_2 should be used as input of Nexus_2, but the API wrongly uses arg_2' instead which !=3D arg_2 due to Nexus_1's map-pass-thru. Fix by always making @match_array point to @initial_match_array into which to store nexus output. Fixes: bd6f2fd5a1d5 ("of: Support parsing phandle argument lists through a = nexus node") Cc: stable@vger.kernel.org Signed-off-by: Zijun Hu --- drivers/of/base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index bf18d5997770eb81e47e749198dd505a35203d10..969b99838655534915882abe358= 814d505c6f748 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1536,7 +1536,6 @@ int of_parse_phandle_with_args_map(const struct devic= e_node *np, * specifier into the out_args structure, keeping the * bits specified in -map-pass-thru. */ - match_array =3D map - new_size; for (i =3D 0; i < new_size; i++) { __be32 val =3D *(map - new_size + i); =20 @@ -1545,6 +1544,7 @@ int of_parse_phandle_with_args_map(const struct devic= e_node *np, val |=3D cpu_to_be32(out_args->args[i]) & pass[i]; } =20 + initial_match_array[i] =3D val; out_args->args[i] =3D be32_to_cpu(val); } out_args->args_count =3D list_size =3D new_size; --=20 2.34.1 From nobody Mon Feb 9 03:43:09 2026 Received: from pv50p00im-zteg10011401.me.com (pv50p00im-zteg10011401.me.com [17.58.6.41]) (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 D5909218AAB for ; Thu, 9 Jan 2025 13:28:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429295; cv=none; b=FYKx0cIQvIjrYuDe3p7VY0jjNE54ZEcajcIZVncIrSjO8gcZBJ6vpm9u+bPHPdIwpvHZXEunbRkxnv2EOyRBA0f56f2JWoCSVM1y63Z9WbePhRBwoPxZ/bd7aanNRy7WqzKS60Vu2CnpxrIO2umKREw/qk3ny8vHwlBXvUEnVHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429295; c=relaxed/simple; bh=uSgl6tmpjcKrpfU+/rRT4WEOic2miN6oQ63t67Qe7qc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XyLoyR7qEAA5kko9SqxldHHiQ8JH9SWqo2VjyDHNYPezTLNRVKuIx1JSmafrBDPZbBan2NBEiOPTB8TpDEkXAMhm1mTuHO6acbv4rOuzQ4L78UD2ZYr9TeCtrGTfS8bt0QsJM8pGInt+1WVNc1dc2roQwUoUVbiwcCEQ2l1p6N8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=Ot+a3Kg4; arc=none smtp.client-ip=17.58.6.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="Ot+a3Kg4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1736429293; bh=lxh3lTkHEDaNLjOBBiXkDjAykRGLwhRpR2ibcxXXYlY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=Ot+a3Kg40Ce1n953u8pFd4eVZiE5D4zWXNwCip+izENcICL1VHEzp87CxpmatdCQl phKvPAeM6EiWOOTCrfZeB64FcmCY/c45INsaRfWT5nnN1hRsdFrGOicvM+rmdtOCm+ 6Fkld2yBehuHBjEoSCqrI6zwVPJDKhz9jmGcOpgnU5/fQwGp3gzyrcy2GAU+Q87BC4 NZFe/lUaSpfdEflnQ3JSydZ8cV6nD3xkO7ntNx2ZM2yH2rN8VtdXP7WVCkoIqbXNEW 8qpaOP+SqD4GgeenHeFMhw3tNJ8RzTbU5NznCBD32fHy4zaQ/MReTE/kLuy16KDTaa 0KKz1Vv/CXogQ== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10011401.me.com (Postfix) with ESMTPSA id 57BFA34BAA94; Thu, 9 Jan 2025 13:28:08 +0000 (UTC) From: Zijun Hu Date: Thu, 09 Jan 2025 21:26:53 +0800 Subject: [PATCH v4 02/14] of: Do not expose of_alias_scan() and correct its comments Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250109-of_core_fix-v4-2-db8a72415b8c@quicinc.com> References: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> In-Reply-To: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> To: Rob Herring , Saravana Kannan , Maxime Ripard , Robin Murphy , Grant Likely , Marc Zyngier , Andreas Herrmann , Marek Szyprowski , Catalin Marinas , Mike Rapoport , Oreoluwa Babatunde Cc: Zijun Hu , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-GUID: 94Z9K7bOSa_MFRxgzsJ8FlMdjPif0lRD X-Proofpoint-ORIG-GUID: 94Z9K7bOSa_MFRxgzsJ8FlMdjPif0lRD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-09_05,2025-01-09_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2501090108 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu For of_alias_scan(): - Do not expose it since it has no external callers. - Correct its comments shown below: 1) Replace /* with /** to start comments since it is not a API. 2) Delete return value descriptions since it is a void function. Signed-off-by: Zijun Hu --- drivers/of/base.c | 5 ++--- drivers/of/of_private.h | 2 ++ drivers/of/pdt.c | 2 ++ include/linux/of.h | 1 - 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index 969b99838655534915882abe358814d505c6f748..5485307e2a3a3d3a216d271c60b= dfc346dd38460 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1806,14 +1806,13 @@ static void of_alias_add(struct alias_prop *ap, str= uct device_node *np, ap->alias, ap->stem, ap->id, np); } =20 -/** +/* * of_alias_scan - Scan all properties of the 'aliases' node * @dt_alloc: An allocator that provides a virtual address to memory * for storing the resulting tree * * The function scans all the properties of the 'aliases' node and populat= es - * the global lookup table with the properties. It returns the - * number of alias properties found, or an error code in case of failure. + * the global lookup table with the properties. */ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)) { diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index ea5a0951ec5e107bab265ab5f6c043e2bfb15ecc..3433ccd330e84fd3a4b54638e0e= 922069757c8f0 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -119,6 +119,8 @@ extern void *__unflatten_device_tree(const void *blob, void *(*dt_alloc)(u64 size, u64 align), bool detached); =20 +void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)); + /** * General utilities for working with live trees. * diff --git a/drivers/of/pdt.c b/drivers/of/pdt.c index 7eda43c66c916198b1c2d8fc5043fcb1edaede7a..cb0cb374b21ff89323e11f34bd7= 67b183e7a401e 100644 --- a/drivers/of/pdt.c +++ b/drivers/of/pdt.c @@ -19,6 +19,8 @@ #include #include =20 +#include "of_private.h" + static struct of_pdt_ops *of_pdt_prom_ops __initdata; =20 #if defined(CONFIG_SPARC) diff --git a/include/linux/of.h b/include/linux/of.h index f921786cb8ac782286ed5ff4425a35668204d050..d451c46132b01efe6d4e0b6cf83= a3e2084bb3ec6 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -397,7 +397,6 @@ extern int of_phandle_iterator_args(struct of_phandle_i= terator *it, uint32_t *args, int size); =20 -extern void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)); extern int of_alias_get_id(const struct device_node *np, const char *stem); extern int of_alias_get_highest_id(const char *stem); =20 --=20 2.34.1 From nobody Mon Feb 9 03:43:09 2026 Received: from pv50p00im-zteg10011401.me.com (pv50p00im-zteg10011401.me.com [17.58.6.41]) (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 D59A4218AC9 for ; Thu, 9 Jan 2025 13:28:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429301; cv=none; b=tPGojLPmQ94h+MlbL+Cn2a3YEuhmqEklbHfUw6Bq+QAZzCHGWyDphem3ZjV195qjTMv230Ocs+vhHruyIHSRXqNU8cQZzaC4Jwyg0ppVfOdDs9nP9TT/pJw5ygWvlvU81U+AUEtMtu1D4xTWpYLzRXX+5s7pjoqmDmOz+8TOolM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429301; c=relaxed/simple; bh=hhxEV0PSOUDlgXbkxbGpMJBooUyQNe8CgBoY6/KKj6o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=A9EycQTVMp4CFhdKaeG2d0vgqbqyv7xstrdn3CcZyNLnns93SAQGcBxLyseRIuLdHfrgNWbyWolwZpIMPB0AofioiK4DGk2OCR5roLtqaXzblo5gMH0UNrh3imJQTapyNv2aO+3Y7VDAxH+dzHtyKtG3oCGEuxDWyekUsv83rVo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=Zi16uDjv; arc=none smtp.client-ip=17.58.6.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="Zi16uDjv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1736429299; bh=voAtwf0WkjLnq9xLBA6Vyr9IuEpPzAqCBFAvUL3PwiI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=Zi16uDjv8tzlDOgqLsGRUKtbaiDQkm2oI4xcXVbpxA62idGQPw9Za5QVk0fNA882L T5O+VZWoXlxuIpEz1VDL038ZhBuOY/ETKOKxKduo8ureX66zU+XvNHMZHLJQkttS96 g5ujxZe5gJQSo05RUQv7a5cYODW/OpSE2ya8XmJsJtrSiFb4W73ZJW9Jdvber0ZPKo Dwe49p0/91NZU5DL/X4cQIpHfY7eygWuRVBtp7Vd3AZ+3aD3pw+twyEAIBmrd29mk3 sy6ZNYiTe8nA9zbAh1ApfzNp/4h5Zi2+Zy70qO56m2hFz59ySiJzrbcWfSTWYg7Wji B2EVcF5PBmYrw== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10011401.me.com (Postfix) with ESMTPSA id 1934934BAA1E; Thu, 9 Jan 2025 13:28:13 +0000 (UTC) From: Zijun Hu Date: Thu, 09 Jan 2025 21:26:54 +0800 Subject: [PATCH v4 03/14] of: Make of_property_present() applicable to all kinds of property Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250109-of_core_fix-v4-3-db8a72415b8c@quicinc.com> References: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> In-Reply-To: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> To: Rob Herring , Saravana Kannan , Maxime Ripard , Robin Murphy , Grant Likely , Marc Zyngier , Andreas Herrmann , Marek Szyprowski , Catalin Marinas , Mike Rapoport , Oreoluwa Babatunde Cc: Zijun Hu , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-GUID: R1MP36i3a-RVMZzTJ-h2CBM6pEAKwsrZ X-Proofpoint-ORIG-GUID: R1MP36i3a-RVMZzTJ-h2CBM6pEAKwsrZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-09_05,2025-01-09_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=792 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2501090108 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu API of_property_present() invokes of_property_read_bool() to check if a property is present or not, and that has 2 shortcomings shown below: - That narrows down property scope applicable to of_property_present() from all kinds of property to only bool type. - That is less logical since it says a property's presence is decided by its bool property value. Fix by making of_property_read_bool() invoke of_property_present(). Signed-off-by: Zijun Hu --- include/linux/of.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/include/linux/of.h b/include/linux/of.h index d451c46132b01efe6d4e0b6cf83a3e2084bb3ec6..fe5d7b74c23b9701743f5debc3d= 030b765bc914f 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -1242,17 +1242,16 @@ static inline int of_property_read_string_index(con= st struct device_node *np, } =20 /** - * of_property_read_bool - Find a property - * @np: device node from which the property value is to be read. + * of_property_present - Test if a property is present in a node + * @np: device node to search for the property. * @propname: name of the property to be searched. * - * Search for a boolean property in a device node. Usage on non-boolean - * property types is deprecated. + * Test for a property present in a device node. * * Return: true if the property exists false otherwise. */ -static inline bool of_property_read_bool(const struct device_node *np, - const char *propname) +static inline bool of_property_present(const struct device_node *np, + const char *propname) { const struct property *prop =3D of_find_property(np, propname, NULL); =20 @@ -1260,17 +1259,19 @@ static inline bool of_property_read_bool(const stru= ct device_node *np, } =20 /** - * of_property_present - Test if a property is present in a node - * @np: device node to search for the property. + * of_property_read_bool - Find a property + * @np: device node from which the property value is to be read. * @propname: name of the property to be searched. * - * Test for a property present in a device node. + * Search for a boolean property in a device node. Usage on non-boolean + * property types is deprecated. * * Return: true if the property exists false otherwise. */ -static inline bool of_property_present(const struct device_node *np, const= char *propname) +static inline bool of_property_read_bool(const struct device_node *np, + const char *propname) { - return of_property_read_bool(np, propname); + return of_property_present(np, propname); } =20 /** --=20 2.34.1 From nobody Mon Feb 9 03:43:09 2026 Received: from pv50p00im-zteg10011401.me.com (pv50p00im-zteg10011401.me.com [17.58.6.41]) (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 BF57E218E81 for ; Thu, 9 Jan 2025 13:28:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429307; cv=none; b=MjAZSpo24c16xoJT8yzIny0Azq2AapXP62GXwkmGZyGljwcJWjE1pWaBPd/quYpw0r5nIwf3RbEyzTjAj5IonHuvco3KIxuYFd4ZlhWUVpAqP+urcN4I44X1wtR3oblJnIW0+4OxfXIk1GtC4EZGfSnDpeK1kkRIsP0vOfX1b/c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429307; c=relaxed/simple; bh=80kccgYvnj9G84Nx3IR+WA53NzpjDh/0RaEOK5puNy8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HS9cLS6AxoskYPbocmDVCg4NyYe/cn8LKFGDeFfF2mvdbYMP6ecTMNYGLwximLbTzLY5uRmEQk+Au1/ZIu1ZvmuwcK4jkJ9NOCH8mTRLHYvgLJ+TdFO9ofV5DLhLpt3/Rmer0TgEOtl6hHyGfdMWxMBaWUYkjmnwSEZ9scnDc58= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=aH/3opQg; arc=none smtp.client-ip=17.58.6.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="aH/3opQg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1736429305; bh=lMZVZTNsgFOCxTCYXq6jCFsMl6EKNzODNeFIS1bvHJg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=aH/3opQgZzMKVDIwkHeb7UgA/QKLtOoWv2DXfz0sLNhxXUxyL9IoPe67kJXvaEtk3 tivjr77641FrzPoQFAplN26KJ3bZk8wqGHg8v7cdsxjwWNt4wivutZK4ycGBLmipY6 6RVqhfu5ctxvmV9HdrY94Nqo03uibQdhio/dLmaeo0AhYrIJZoITXRkIu4dUqDfSZQ mBLphN6Sn8c8oysbS84/Wyw2VwM1P60qofeO3XMkZP5n7AT5wphrKX5UzUZiLJ0rVh LlY2S8By6pxclswvAzRabPNg2FQ/4vVoOLgUu/mduQEr6wix0PUPCmY5wQgfQyY/0y eC7Hc217YnC3w== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10011401.me.com (Postfix) with ESMTPSA id DD5B534BAA77; Thu, 9 Jan 2025 13:28:19 +0000 (UTC) From: Zijun Hu Date: Thu, 09 Jan 2025 21:26:55 +0800 Subject: [PATCH v4 04/14] of: property: Use of_property_present() for of_fwnode_property_present() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250109-of_core_fix-v4-4-db8a72415b8c@quicinc.com> References: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> In-Reply-To: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> To: Rob Herring , Saravana Kannan , Maxime Ripard , Robin Murphy , Grant Likely , Marc Zyngier , Andreas Herrmann , Marek Szyprowski , Catalin Marinas , Mike Rapoport , Oreoluwa Babatunde Cc: Zijun Hu , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-GUID: hxgLa_XSkJDj_1KlQ5Jg57sJg8To2bAN X-Proofpoint-ORIG-GUID: hxgLa_XSkJDj_1KlQ5Jg57sJg8To2bAN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-09_05,2025-01-09_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2501090108 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu Use of_property_present() instead of of_property_read_bool() for of_fwnode_property_present() since the former is more applicable obviously. Signed-off-by: Zijun Hu --- Hi Rob, i pick up this change again after some considerations as below: 1) of_property_present() is more suitable than of_property_read_bool() here, deprecated API is not main reason. 2) it does not conflict with your job which warns when use of_property_read_bool() for non-bool property. --- drivers/of/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index 519bf9229e613906547b57d8c68e7b8558eff327..dca1a3ebccae1093b2b11f51e8e= 692bca854d0e3 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -966,7 +966,7 @@ of_fwnode_device_get_dma_attr(const struct fwnode_handl= e *fwnode) static bool of_fwnode_property_present(const struct fwnode_handle *fwnode, const char *propname) { - return of_property_read_bool(to_of_node(fwnode), propname); + return of_property_present(to_of_node(fwnode), propname); } =20 static int of_fwnode_property_read_int_array(const struct fwnode_handle *f= wnode, --=20 2.34.1 From nobody Mon Feb 9 03:43:09 2026 Received: from pv50p00im-zteg10011401.me.com (pv50p00im-zteg10011401.me.com [17.58.6.41]) (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 57122218E82 for ; Thu, 9 Jan 2025 13:28:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429312; cv=none; b=DltEKjBeCTejaTquydBMdZqrPIaLRAeu/L6KiLN+SEER8kvjmQN4NGim9fynMtfj0JxIVARAdV4aLV7ogU0Y0jy+RgRWWWnWLf/SZC/MGhOsepA6/hDOWT1Ib4BD/JSroH4EoTqjG8OWbv0e/+SqEHHw5N11tkCEmrfdtUmeLRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429312; c=relaxed/simple; bh=bc6lzGgIEQ1cBkFQ7KiFXTLCSQur3IQsBxM4lNEjjT8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P/lulkWk+aQtn4M0alV9ycRmyx5KJFH/LrkNp2FGmM/Ys+uzBDFDE9rQ6ACaitZdPejte7yBUYROZvZjRsYoq9RSexm3Ee/DIIyhGftDIUXrIHWC0OzTQMzO/peO8XjwzQrjftFWyj+GfQzLV/4K8APjmiDXa5vE6GxqWO3NSEU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=zy7rSUXm; arc=none smtp.client-ip=17.58.6.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="zy7rSUXm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1736429311; bh=2a/BC8NRIh0uh85HCJfRd8BdlVkBEXk7Aqyv3gynJAM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=zy7rSUXmkus7HexLxBcV84qoD/XumqA+L3xN522a38Gqx5OXRR4Izkn2IDJ+G5UD8 dIwHfvkTwx9ia1aqXTfS8d/4Qsa7YyRYmq2C50gsNk78MX0Mc/rS7yjxJDRgn7jgEG 15Rh8zllyG395g/U7AP9rU5m2RBoyTmEGRXb9pwAs3pyquXpoILw3+kwDr+wfms3hB N/XkiK1oea3JUxhztA85BLqONx8Da0U6PSguoNlzVnkkmzvVJymaQLMVQ04U+31bxE rJTH/tHRsBJ6lN+ChNw6RA+muYbnTDXFkIdTnMbZ+/9Mph+c+81lQCprgbG4edVOp6 +RCyDyubgXGkQ== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10011401.me.com (Postfix) with ESMTPSA id EF7A934BA9F0; Thu, 9 Jan 2025 13:28:25 +0000 (UTC) From: Zijun Hu Date: Thu, 09 Jan 2025 21:26:56 +0800 Subject: [PATCH v4 05/14] of: Fix available buffer size calculating error in API of_device_uevent_modalias() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250109-of_core_fix-v4-5-db8a72415b8c@quicinc.com> References: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> In-Reply-To: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> To: Rob Herring , Saravana Kannan , Maxime Ripard , Robin Murphy , Grant Likely , Marc Zyngier , Andreas Herrmann , Marek Szyprowski , Catalin Marinas , Mike Rapoport , Oreoluwa Babatunde Cc: Zijun Hu , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-GUID: 34RVrnDgEFOXyeM9Ufz85vXOBdzZSPdw X-Proofpoint-ORIG-GUID: 34RVrnDgEFOXyeM9Ufz85vXOBdzZSPdw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-09_05,2025-01-09_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2501090108 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu of_device_uevent_modalias() saves MODALIAS value from offset (@env->buflen - 1), so the available buffer size should be (sizeof(@env->buf) - @env->buflen + 1), but it uses the wrong size (sizeof(@env->buf) - @env->buflen). Fix by using size of space from char '\0' inclusive which ends "MODALIAS=3D= ". Fixes: dd27dcda37f0 ("of/device: merge of_device_uevent") Signed-off-by: Zijun Hu --- drivers/of/device.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/of/device.c b/drivers/of/device.c index edf3be1972658f6dc165f577da53b10c7eebc116..f24c19e7aba8e01656f503ae328= a4e08aab5a5f3 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -257,6 +257,7 @@ EXPORT_SYMBOL_GPL(of_device_uevent); int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent= _env *env) { int sl; + int pos; =20 if ((!dev) || (!dev->of_node) || dev->of_node_reused) return -ENODEV; @@ -265,13 +266,18 @@ int of_device_uevent_modalias(const struct device *de= v, struct kobj_uevent_env * if (add_uevent_var(env, "MODALIAS=3D")) return -ENOMEM; =20 - sl =3D of_modalias(dev->of_node, &env->buf[env->buflen-1], - sizeof(env->buf) - env->buflen); + /* + * @env->buflen is pointing to the char after '\0' now + * override the '\0' to save MODALIAS value. + */ + pos =3D env->buflen - 1; + sl =3D of_modalias(dev->of_node, &env->buf[pos], + sizeof(env->buf) - pos); if (sl < 0) return sl; - if (sl >=3D (sizeof(env->buf) - env->buflen)) + if (sl >=3D (sizeof(env->buf) - pos)) return -ENOMEM; - env->buflen +=3D sl; + env->buflen =3D pos + sl + 1; =20 return 0; } --=20 2.34.1 From nobody Mon Feb 9 03:43:09 2026 Received: from pv50p00im-zteg10011401.me.com (pv50p00im-zteg10011401.me.com [17.58.6.41]) (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 5534F218E97 for ; Thu, 9 Jan 2025 13:28:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429318; cv=none; b=rei2eE72ScaZ73QOPedDUGxXRsVAx7eZzd7cWm+HA6L89O3h9v4veoKqVEGkCi6B4Z2Ke9C3rYNsiLe8HmOdhr7Wx3bL/v1EGe54nGb+0kJSlziL269AJYrMX6XYCeD+Vb543JPSgqoVWdKlSByP4mijD7M/ae9u+1ldqsu7h5A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429318; c=relaxed/simple; bh=3z4V5ybLpT+xjDr+qnxjyHgY4D4/CYeGXidyOPPVLmc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VU/wMhDT9LU4npBR+6qxKQBgv4SVtMhS8vV07avOvq4YwX36WxrYQbupLt/o9/fYpokQOJOLUz7Q6DkF6F6zHnJb4TVf11xHMQQzfziOS1PCq5etwPQ2gV+ETZ+OQO7eDCzIOMPX+UHi3SNPZiSti/E6m4zYmGyewS5UWq6NZcA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=Oesz59UH; arc=none smtp.client-ip=17.58.6.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="Oesz59UH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1736429316; bh=PZISBSf27wTtYLKEeEtnWRnUJBoKGGJD6tN4PU1vK5k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=Oesz59UHL30Dn3RJ45UbukBcujcbR1dijuT/kdvfctpy/yz/LwQJ7c+T82fF/1y1A O/9VkxLf/wz+3OxeLy0lwx9fTR1n+4NfPpkcS7/t29yKksDcUurYmkb1wjipalJxGn GfqCQgrJtPjlFDxd7BlJS/TBvidpQkvU00Hps/P/lMwhpi+LsXSimID6cb3ToW+v3+ hWE4nFJBRz5g8gli6bxbJlUepOZ5ZvfjHpI66i6zHhi1xFgXiU2bYtHoV+9U1EZM3v TF6jTIEmV3YFH53xjOtD62wg/l4194CJ0MDNTVdjFvMNuLQYLX/CP2M8qocUmmFvdS zrwhvAip41YtQ== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10011401.me.com (Postfix) with ESMTPSA id B633834BA66B; Thu, 9 Jan 2025 13:28:31 +0000 (UTC) From: Zijun Hu Date: Thu, 09 Jan 2025 21:26:57 +0800 Subject: [PATCH v4 06/14] of: property: Avoiding using uninitialized variable @imaplen in parse_interrupt_map() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250109-of_core_fix-v4-6-db8a72415b8c@quicinc.com> References: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> In-Reply-To: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> To: Rob Herring , Saravana Kannan , Maxime Ripard , Robin Murphy , Grant Likely , Marc Zyngier , Andreas Herrmann , Marek Szyprowski , Catalin Marinas , Mike Rapoport , Oreoluwa Babatunde Cc: Zijun Hu , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-GUID: eWZFKMgtrvbEi97CK9id-c9GRRKqiE1D X-Proofpoint-ORIG-GUID: eWZFKMgtrvbEi97CK9id-c9GRRKqiE1D X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-09_05,2025-01-09_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=920 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2501090108 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu parse_interrupt_map() will use uninitialized variable @imaplen if fails to get property 'interrupt-map'. Fix by using the variable after successfully getting the property. Fixes: e7985f43609c ("of: property: Fix fw_devlink handling of interrupt-ma= p") Signed-off-by: Zijun Hu Reviewed-by: Krzysztof Kozlowski --- drivers/of/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index dca1a3ebccae1093b2b11f51e8e692bca854d0e3..6245cbff3527d762c16e7f4b7b7= b3d4f2e9ddbe6 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1391,9 +1391,9 @@ static struct device_node *parse_interrupt_map(struct= device_node *np, addrcells =3D of_bus_n_addr_cells(np); =20 imap =3D of_get_property(np, "interrupt-map", &imaplen); - imaplen /=3D sizeof(*imap); if (!imap) return NULL; + imaplen /=3D sizeof(*imap); =20 imap_end =3D imap + imaplen; =20 --=20 2.34.1 From nobody Mon Feb 9 03:43:09 2026 Received: from pv50p00im-zteg10011401.me.com (pv50p00im-zteg10011401.me.com [17.58.6.41]) (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 1EFE221A421 for ; Thu, 9 Jan 2025 13:28:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429325; cv=none; b=BbRlF03sq/zWw1olfM4Dl9UWoIxY5oPPwMFK++mamk03nL0o4OmecZaICxLP9RALRUozaSRh1MS+A1PqjVK3r29JHDa4QwKPvMGufswAqhAhGRgBFH3C6MjvH7rw7IObUvt2mPiffyzxe6HywEGV9mgxicmnPUMdAGEw336CKiQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429325; c=relaxed/simple; bh=jW2pt1kirzv476fWJ3VnMBI4Flqc/IZzotnFaTMJyAY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=etaXxGqlMsrGrlBOApbFOC9LhqqNWInXlUV2LV71+pyf2LbZ3ztuAacI4p9cz51Os3OapBCqKhkD5gZ3w3xxr3ETZR+CP2uMRrwhdIPF/WdRxnfTTUB69zaLj3j3tqLDCUgCIY4FbSC3e1CAswLKU1yS/2DV9WPqRtvC8/tUlrI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=XcQtMVev; arc=none smtp.client-ip=17.58.6.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="XcQtMVev" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1736429322; bh=Ak+4DAJjixtYTkxuqIXBIgZjCkGC+Pi0wIvtasZPM64=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=XcQtMVevLldkj0JDUBoEiPgn445sGGzAbJSIjBcCG4tj0a2cH/RP6avHlY1i00sRW LnRuvzY1HseYo0fyVHjTYsGExjdj4r77epCts49BFKe7UQf1XClfkKRBWELQJ5YvRk lobJzgyt4W8OIdQTovQ+JDxA1K42EAId+gAALIm+28ghPBoMm3HRw4+rUvm+mhAyRa DFuIxI7Y9NQGX6FNR9Y+1D31D6VKeA0qnxFi5yN85eUQiYIydlCAsECshwA/bEDR1i A76WK5ujTd+MuZ20/+1QEs8x7kRIFSTiF5sojbhYhHD1aNl6vZyZlnZZdmLyIq/VCs QyglNXmiy7hig== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10011401.me.com (Postfix) with ESMTPSA id 8C54634BAAE7; Thu, 9 Jan 2025 13:28:37 +0000 (UTC) From: Zijun Hu Date: Thu, 09 Jan 2025 21:26:58 +0800 Subject: [PATCH v4 07/14] of: property: Fix potential fwnode reference's argument count got out of range Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250109-of_core_fix-v4-7-db8a72415b8c@quicinc.com> References: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> In-Reply-To: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> To: Rob Herring , Saravana Kannan , Maxime Ripard , Robin Murphy , Grant Likely , Marc Zyngier , Andreas Herrmann , Marek Szyprowski , Catalin Marinas , Mike Rapoport , Oreoluwa Babatunde Cc: Zijun Hu , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-GUID: Hw1KZoDix76YYdmiNU9ZOb6MCN-krsqi X-Proofpoint-ORIG-GUID: Hw1KZoDix76YYdmiNU9ZOb6MCN-krsqi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-09_05,2025-01-09_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=909 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2501090108 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu Currently, the maximal fwnode reference argument count supported is 8, and the maximal OF node phandle argument count supported is 16, but of_fwnode_get_reference_args() directly assigns OF node phandle count @of_args.args_count to fwnode reference count @args->nargs, so may cause fwnode reference argument count got is out of range, namely, in [9, 16]. Fix by truncating @args->nargs got to 8 and warning if it > 8. Fixes: b66548e2a9ba ("of: Increase MAX_PHANDLE_ARGS") Signed-off-by: Zijun Hu --- drivers/of/property.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/of/property.c b/drivers/of/property.c index 6245cbff3527d762c16e7f4b7b7b3d4f2e9ddbe6..5ef9b2ced43ee7c4bfe88ea3cb1= 1f3182da0dab9 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1072,6 +1072,11 @@ of_fwnode_get_reference_args(const struct fwnode_han= dle *fwnode, } =20 args->nargs =3D of_args.args_count; + if (args->nargs > NR_FWNODE_REFERENCE_ARGS) { + pr_warn("%s: Truncate arg count %d for property '%s' phandle index %d\n", + __func__, of_args.args_count, prop, index); + args->nargs =3D NR_FWNODE_REFERENCE_ARGS; + } args->fwnode =3D of_fwnode_handle(of_args.np); =20 for (i =3D 0; i < NR_FWNODE_REFERENCE_ARGS; i++) --=20 2.34.1 From nobody Mon Feb 9 03:43:09 2026 Received: from pv50p00im-zteg10011401.me.com (pv50p00im-zteg10011401.me.com [17.58.6.41]) (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 37C27218EB1 for ; Thu, 9 Jan 2025 13:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429330; cv=none; b=FdscGDs9M6/7O27lsZhFAez4+WppoajZQVWxyGpI9pUkkgjbroXdfikpWWR365jSZNZxAUytLEIUZa0GU54zvHL8TVzienVlcVCZRiAZ+RbX/zP6nG0Qqi0q86ELENnSFggNJFgjpH1RoiF3QcA0ixdYWVg4mwddTdbJ+IOP8F8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429330; c=relaxed/simple; bh=psQUOW6Ky/zN+kinWs20f1Lj9NsDSxPYQ+WCCxrQ7HA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KhVPUqXBb/2TAX7OsVy9yErkwzILNeu6QCvVVTQRGKLvsqI3M13tWRrpIPe+DS1ATiII1L8mbF5mYtMY4HGHWAI0bIeMiB0ATxdUK9busj4wettcQegaz6MyyFvUv3MsN3F+LyW8f6V60IeTWinSiPibSSqQ5jZNB2nlA7Klzvk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=h5V5IXt3; arc=none smtp.client-ip=17.58.6.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="h5V5IXt3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1736429329; bh=s5OvC1NKLXgRIdO4zIttIC5hFiXGsvYigo7n737f4Yk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=h5V5IXt3jMd8+oDdujuzctfDgE/Tr/coNG13SZ3GKkVm6XcGjcP2OrjitQG7iY96k jaASLIjWOWaZiK1wzP6XlP/j8ymz58FCjoz9vkwYkr8t725mN3ymabMnL65buCTmG8 NOzI3tLZh37kjYeGXBPfbPRNqs23fhkV4AI70Az0G7YIDwFVmFq2zjQX3IDvI7LZhn nsRi90etZlmeoIreN2QKVytq2YH6gFsx5rVrX1/PHVu5JMBqzHBUg8mmE+2jjAwFBp H6Avz3JI/ajr2EWOiBUGRNpL2vqwwG6R4WOpbhm3X9+WevPAujaMgZ8HxGp269smP4 BmN+GRMwMgsQA== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10011401.me.com (Postfix) with ESMTPSA id 508CE34BAAB2; Thu, 9 Jan 2025 13:28:43 +0000 (UTC) From: Zijun Hu Date: Thu, 09 Jan 2025 21:26:59 +0800 Subject: [PATCH v4 08/14] of: Remove a duplicated code block Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250109-of_core_fix-v4-8-db8a72415b8c@quicinc.com> References: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> In-Reply-To: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> To: Rob Herring , Saravana Kannan , Maxime Ripard , Robin Murphy , Grant Likely , Marc Zyngier , Andreas Herrmann , Marek Szyprowski , Catalin Marinas , Mike Rapoport , Oreoluwa Babatunde Cc: Zijun Hu , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-GUID: nhLpPXVM_wlM-AtjEAkHZJP050pA2sQ5 X-Proofpoint-ORIG-GUID: nhLpPXVM_wlM-AtjEAkHZJP050pA2sQ5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-09_05,2025-01-09_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2501090108 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu address.c has a same code block with fdt_address.c. Remove a copy by moving the duplicated code block into of_private.h. Signed-off-by: Zijun Hu --- drivers/of/address.c | 21 +++------------------ drivers/of/fdt_address.c | 21 ++++----------------- drivers/of/of_private.h | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 35 deletions(-) diff --git a/drivers/of/address.c b/drivers/of/address.c index c5b925ac469f16b8ae4b8275b60210a2d583ff83..6c40f96a19610c19d9594a9605f= d9a2fa2c97cd4 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -16,25 +16,10 @@ #include #include /* for bus_dma_region */ =20 -#include "of_private.h" - -/* Max address size we deal with */ -#define OF_MAX_ADDR_CELLS 4 -#define OF_CHECK_ADDR_COUNT(na) ((na) > 0 && (na) <=3D OF_MAX_ADDR_CELLS) -#define OF_CHECK_COUNTS(na, ns) (OF_CHECK_ADDR_COUNT(na) && (ns) > 0) +/* Uncomment me to enable of_dump_addr() debugging output */ +// #define DEBUG =20 -/* Debug utility */ -#ifdef DEBUG -static void of_dump_addr(const char *s, const __be32 *addr, int na) -{ - pr_debug("%s", s); - while (na--) - pr_cont(" %08x", be32_to_cpu(*(addr++))); - pr_cont("\n"); -} -#else -static void of_dump_addr(const char *s, const __be32 *addr, int na) { } -#endif +#include "of_private.h" =20 /* Callbacks for bus specific translators */ struct of_bus { diff --git a/drivers/of/fdt_address.c b/drivers/of/fdt_address.c index 1e5311f6f1858b59b99f650bcafa55a8d11225f9..f358d2c807540e79fdd72a7e9a5= 328bccd88476d 100644 --- a/drivers/of/fdt_address.c +++ b/drivers/of/fdt_address.c @@ -17,23 +17,10 @@ #include #include =20 -/* Max address size we deal with */ -#define OF_MAX_ADDR_CELLS 4 -#define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <=3D OF_MAX_ADDR_CELLS &= & \ - (ns) > 0) - -/* Debug utility */ -#ifdef DEBUG -static void __init of_dump_addr(const char *s, const __be32 *addr, int na) -{ - pr_debug("%s", s); - while(na--) - pr_cont(" %08x", be32_to_cpu(*(addr++))); - pr_cont("\n"); -} -#else -static void __init of_dump_addr(const char *s, const __be32 *addr, int na)= { } -#endif +/* Uncomment me to enable of_dump_addr() debugging output */ +// #define DEBUG + +#include "of_private.h" =20 /* Callbacks for bus specific translators */ struct of_bus { diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index 3433ccd330e84fd3a4b54638e0e922069757c8f0..f3e1193c8ded4899f39677a76da= 073e2266a1b9a 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -190,4 +190,22 @@ void __init fdt_scan_reserved_mem_reg_nodes(void); =20 bool of_fdt_device_is_available(const void *blob, unsigned long node); =20 +/* Max address size we deal with */ +#define OF_MAX_ADDR_CELLS 4 +#define OF_CHECK_ADDR_COUNT(na) ((na) > 0 && (na) <=3D OF_MAX_ADDR_CELLS) +#define OF_CHECK_COUNTS(na, ns) (OF_CHECK_ADDR_COUNT(na) && (ns) > 0) + +/* Debug utility */ +#ifdef DEBUG +static void __maybe_unused of_dump_addr(const char *s, const __be32 *addr,= int na) +{ + pr_debug("%s", s); + while (na--) + pr_cont(" %08x", be32_to_cpu(*(addr++))); + pr_cont("\n"); +} +#else +static void __maybe_unused of_dump_addr(const char *s, const __be32 *addr,= int na) { } +#endif + #endif /* _LINUX_OF_PRIVATE_H */ --=20 2.34.1 From nobody Mon Feb 9 03:43:09 2026 Received: from pv50p00im-zteg10011401.me.com (pv50p00im-zteg10011401.me.com [17.58.6.41]) (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 6BE85218EBD for ; Thu, 9 Jan 2025 13:28:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429336; cv=none; b=kOIhY1Yl2/CnUO4kegSIR+pFtVXs2DnD4Vk8isz+8EUuyynd9dW77mQeVWgjgLGwMuq1n28ePuMkhtP/EvrPELSC1j0yeVmtzxKtW9WAiWHGwsujKiSKgSsUWMxbyvRaq9Vbtw3iWPb1HlJfaJsnkjuG4KBrEKXGDTjxf1sBZdA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429336; c=relaxed/simple; bh=b/pklCdjN2LibMahnmkwgupW91Dgcx1mcf8XUscWfP4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bMRn4VrC+t8zwFebi5iBe0PYT7OFS4+GYUJ3xzFU7k1VEF64DcleHwUcoUjM2/TRItUc61BKLiPg31oqmptnPLbTbanIaVMbHBo/s8kUak77A8EXzrpCsgdlbaALIcDS7CO5qfKWDMb3/8mxLOveigyk4cgo3c/+gjF3l7Tj9aw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=qgEN2vL3; arc=none smtp.client-ip=17.58.6.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="qgEN2vL3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1736429335; bh=ZVUK9tSkNBSa1HB8rrwKraJSfeEd9vaKx7+agQUGQMw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=qgEN2vL3Bf9C9J8NjqbtXPUdP75KW7ZBJaFXvg8/i69u7V1WQQ7zb2xTvXBEOvdfH R9oP+zRO5vcWoRl5YyD2EfVuoEwIfnndCGU/k2qI3VIQWLJHOuVrwqJFIHfj8hMExF tcD1uvu77YqWAe0utfIhaF5FApnMfNfuHW7ft+tJyEYssQwjCrIULW01DFbfVfl1sO tkYgRMH0RXtrQC/MwNXDW8Kigt9RD56JIqneRzoAwb1Et2w53rQMJJTwg8plM+4EiU Gi0MiE5wR24t5HT7kmPvW7Did3S/ApRq6BeyynD2aaeHOEg3y2dY+1CZrBEW/IO0Rb WV7aQpMeuIPDg== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10011401.me.com (Postfix) with ESMTPSA id 94E5434BAADC; Thu, 9 Jan 2025 13:28:49 +0000 (UTC) From: Zijun Hu Date: Thu, 09 Jan 2025 21:27:00 +0800 Subject: [PATCH v4 09/14] of: reserved-memory: Fix using wrong number of cells to get property 'alignment' Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250109-of_core_fix-v4-9-db8a72415b8c@quicinc.com> References: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> In-Reply-To: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> To: Rob Herring , Saravana Kannan , Maxime Ripard , Robin Murphy , Grant Likely , Marc Zyngier , Andreas Herrmann , Marek Szyprowski , Catalin Marinas , Mike Rapoport , Oreoluwa Babatunde Cc: Zijun Hu , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu , stable@vger.kernel.org X-Mailer: b4 0.14.2 X-Proofpoint-GUID: qQrBuU6ig9ldJpdYx8h7nToBqt31-TIc X-Proofpoint-ORIG-GUID: qQrBuU6ig9ldJpdYx8h7nToBqt31-TIc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-09_05,2025-01-09_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2501090108 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu According to DT spec, size of property 'alignment' is based on parent node=E2=80=99s #size-cells property. But __reserved_mem_alloc_size() wrongly uses @dt_root_addr_cells to get the property obviously. Fix by using @dt_root_size_cells instead of @dt_root_addr_cells. Fixes: 3f0c82066448 ("drivers: of: add initialization code for dynamic rese= rved memory") Cc: stable@vger.kernel.org Signed-off-by: Zijun Hu --- drivers/of/of_reserved_mem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 45517b9e57b1add36bdf2109227ebbf7df631a66..d2753756d7c30adcbd52f57338e= 281c16d821488 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -409,12 +409,12 @@ static int __init __reserved_mem_alloc_size(unsigned = long node, const char *unam =20 prop =3D of_get_flat_dt_prop(node, "alignment", &len); if (prop) { - if (len !=3D dt_root_addr_cells * sizeof(__be32)) { + if (len !=3D dt_root_size_cells * sizeof(__be32)) { pr_err("invalid alignment property in '%s' node.\n", uname); return -EINVAL; } - align =3D dt_mem_next_cell(dt_root_addr_cells, &prop); + align =3D dt_mem_next_cell(dt_root_size_cells, &prop); } =20 nomap =3D of_get_flat_dt_prop(node, "no-map", NULL) !=3D NULL; --=20 2.34.1 From nobody Mon Feb 9 03:43:09 2026 Received: from pv50p00im-zteg10011401.me.com (pv50p00im-zteg10011401.me.com [17.58.6.41]) (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 7EB59218E80 for ; Thu, 9 Jan 2025 13:29:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429343; cv=none; b=ATjvbMgZ3YoEPPC/Fh6DSX2B/JNhIVxkIS/iXgWNvQWbXxYhzXPubgIFsmfoQk6ApWA2e6HlvgBzLu/si4jTY/IKUAqnIsGym7yhGH3y35v4ylilyyZQgAHJfQY3oUARAGpG5c1VX74vU9BfQHqzfH+W2bsJsw+dI9etg2XhsUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429343; c=relaxed/simple; bh=djHI9QaNvRdvMkYQkWhpIntu1Jr72xcPcI7VXA0JBdc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=agRhpCRjnQoR6S0R35cAPlzdS9Ngh91CAoW0ON5Uk0UAFn2CEJ4fIcQPrG2mChw3SMTglUzrGGWs5tGzMfnY9OQDUPAa4BvSFYXQEE28w0sWGjVEcadEGI+7pW4GmAAeL3oBt4o7497v+ln3B77CQzzCM34YS8QjI/J+wRe1lRA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=wYkDvcTo; arc=none smtp.client-ip=17.58.6.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="wYkDvcTo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1736429342; bh=VHN2cTDwwhL4M4NNiTnqYEnr4mSRlDoOGxTUWdvBfV8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=wYkDvcTonPNAn1aINi6N306QytOZbnw3S5jdQlGv+wYihRWQYE+AAJa1UfxSV3A7p 8E1W9csatvofRSczEbJvlzkJ85p1ftCENPsuNuMajSfAX8E+r3MNC+dX++9sW03m7L ue0sDBH9rG3LG93oUoBl154WMPtRUvrK8Argok0YnuPw/ScOlMx8uQvER/Q7jeCZm5 MSRCQ8CjEc7JpzpmljwSIMy8aJzHRueLY1njPeMZlTWZNzcq8BPhdVnFE1+K9fESG2 hMr36DR68QxxB/HGmVq6X2ppceYj4dlaJpGbf/+KhfWx8bWF7QniD3YmQwj5kM1YSR EMQLsy3JhjpCg== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10011401.me.com (Postfix) with ESMTPSA id CDB1D34BAADA; Thu, 9 Jan 2025 13:28:55 +0000 (UTC) From: Zijun Hu Date: Thu, 09 Jan 2025 21:27:01 +0800 Subject: [PATCH v4 10/14] of: reserved-memory: Do not make kmemleak ignore freed address Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250109-of_core_fix-v4-10-db8a72415b8c@quicinc.com> References: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> In-Reply-To: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> To: Rob Herring , Saravana Kannan , Maxime Ripard , Robin Murphy , Grant Likely , Marc Zyngier , Andreas Herrmann , Marek Szyprowski , Catalin Marinas , Mike Rapoport , Oreoluwa Babatunde Cc: Zijun Hu , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-GUID: 3PqQJNLjIOC6dU21eIaYnHtYxDB7TCD4 X-Proofpoint-ORIG-GUID: 3PqQJNLjIOC6dU21eIaYnHtYxDB7TCD4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-09_05,2025-01-09_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=936 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2501090108 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu early_init_dt_alloc_reserved_memory_arch() will free address @base when suffers memblock_mark_nomap() error, but it still makes kmemleak ignore the freed address @base via kmemleak_ignore_phys(). That is unnecessary, besides, also causes unnecessary warning messages: kmemleak_ignore_phys() -> make_black_object() -> paint_ptr() -> kmemleak_warn() // warning message here. Fix by avoiding kmemleak_ignore_phys() when suffer the error. Fixes: 658aafc8139c ("memblock: exclude MEMBLOCK_NOMAP regions from kmemlea= k") Signed-off-by: Zijun Hu --- drivers/of/of_reserved_mem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index d2753756d7c30adcbd52f57338e281c16d821488..03a8f03ed1da165d6d7bf907d93= 1857260888225 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -52,7 +52,8 @@ static int __init early_init_dt_alloc_reserved_memory_arc= h(phys_addr_t size, memblock_phys_free(base, size); } =20 - kmemleak_ignore_phys(base); + if (!err) + kmemleak_ignore_phys(base); =20 return err; } --=20 2.34.1 From nobody Mon Feb 9 03:43:09 2026 Received: from pv50p00im-zteg10011401.me.com (pv50p00im-zteg10011401.me.com [17.58.6.41]) (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 19913219A86 for ; Thu, 9 Jan 2025 13:29:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429350; cv=none; b=QjkokCaKlTCLEgP+uR3Evywl3bDVTLUOX1hUdwgtoG/aBSd+5EliD7Ce79k5FGGy1r4EC8aAp4pFaNUJgEBOkPrfYNL52taVer7tqfX95jzYfpywlMc1Cxi1cAC58deYfVtIkAAMhKLOP2jM1vMb37GA3w92APXcSu3YqqBfyxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429350; c=relaxed/simple; bh=3gkUALn9+NB6/ofCJz/GwddV8tFmIWMBEl64x6rz1hw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Vv5wj3sO7TbMJoPYmTQwthyzZ4s3I72L9CK8etdEmspOd6Y30eRztdTemQMs/Og/vk5QzCIodj16gbwzqZlZPub8jENcG3JLsxO34syhkCyRyTMDjhh5TD6fmzi6Q8wCU3aybRL3EpKkhQWHetT95bypvROSjEjnpj+Yo32th0g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=P404Aq6D; arc=none smtp.client-ip=17.58.6.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="P404Aq6D" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1736429348; bh=RM7PGJ/ggDBiewYKpe35tdRJkSx6Q2TZ8sgtiIjl2gk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=P404Aq6DqSgs1Gm2pcazDfNJ+D1/mWNHALSDB9Tf5lZfBIu1gk4v1adk/SMwEESZW QzcV9DFxeNUW6lZZQKm1p894HV4xI7hicaGiaKDBjav8v5e4+3pwuV5jgaosA7aCMB TvezfoDp8w8aYhjbcw9sNWieXj7Jw8//AWes8kzOemcGXF0Fz4DOh09q6+iH3ZueOn +2BJcHXKc1kPAF7EkwCENv0LHbPlmDWDO7jfq0ByJqujgVuX9NzQU2p1MHT5tS2z11 x9XP6zlJ5B0xXoT++W/Z3dF7cAAOjorefXGEiYCRlIiZeauQz4u8na73wVm/bhhPYJ VEInCwsm6VHag== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10011401.me.com (Postfix) with ESMTPSA id DDDB834BA8E0; Thu, 9 Jan 2025 13:29:02 +0000 (UTC) From: Zijun Hu Date: Thu, 09 Jan 2025 21:27:02 +0800 Subject: [PATCH v4 11/14] of: reserved-memory: Warn for missing static reserved memory regions Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250109-of_core_fix-v4-11-db8a72415b8c@quicinc.com> References: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> In-Reply-To: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> To: Rob Herring , Saravana Kannan , Maxime Ripard , Robin Murphy , Grant Likely , Marc Zyngier , Andreas Herrmann , Marek Szyprowski , Catalin Marinas , Mike Rapoport , Oreoluwa Babatunde Cc: Zijun Hu , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu , stable@vger.kernel.org X-Mailer: b4 0.14.2 X-Proofpoint-GUID: Sx2HeXIt3f-tKm-aNM272E87DfxWy3af X-Proofpoint-ORIG-GUID: Sx2HeXIt3f-tKm-aNM272E87DfxWy3af X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-09_05,2025-01-09_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=651 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2501090108 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu For child node of /reserved-memory, its property 'reg' may contain multiple regions, but fdt_scan_reserved_mem_reg_nodes() only takes into account the first region, and miss remaining regions. Give warning message when missing remaining regions. Fixes: 8a6e02d0c00e ("of: reserved_mem: Restructure how the reserved memory= regions are processed") Cc: stable@vger.kernel.org Signed-off-by: Zijun Hu --- drivers/of/of_reserved_mem.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 03a8f03ed1da165d6d7bf907d931857260888225..e2da88d7706ab3c208386e29f31= 350178e67cd14 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -263,6 +263,11 @@ void __init fdt_scan_reserved_mem_reg_nodes(void) uname); continue; } + + if (len > t_len) + pr_warn("%s() ignores %d regions in node '%s'\n", + __func__, len / t_len - 1, uname); + base =3D dt_mem_next_cell(dt_root_addr_cells, &prop); size =3D dt_mem_next_cell(dt_root_size_cells, &prop); =20 --=20 2.34.1 From nobody Mon Feb 9 03:43:09 2026 Received: from pv50p00im-zteg10011401.me.com (pv50p00im-zteg10011401.me.com [17.58.6.41]) (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 F1E38218E8D for ; Thu, 9 Jan 2025 13:29:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429356; cv=none; b=DofZmcgCdUkWUjwm7WOh+kEFxo2hcFeZRiURPbC64574a/aRi8jMJkD0MtJyG70fuAY477QGIa8FkDyZVMe7U+QHDQftVe1+6GXPkSRsPNEOJ894k9Wdh0yFqnmcr+eE0abVwYLaBGLWWZTpo0dWWcAl0CkeY3CNg50R2mSI4cQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429356; c=relaxed/simple; bh=7Ajw+wcxmDMhgPurtgPRKwGELiv8M0BbpR2Ghf3A6OM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VGFOj9nwgleddrgEujPf5n9eyN0gmoRMW7KwcOUO/GHvrVoJOzOY0MzlEHjY/MQF0lerjeYkjJ3hxauTz+DgPo9F2M0secgb7F/lclCaAyNIWJTQ0EYzQ+v39CZOp+0w0KDQGofAcvE4B+iUxFAbJzzL9NWrPEFHklR4eWSBZjg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=koxds8AO; arc=none smtp.client-ip=17.58.6.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="koxds8AO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1736429354; bh=5DeQxT/e48+OUXdvvSnTp3Oq1EY8EJ44Y9n27c4GUj8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=koxds8AO5fjiW32Je1zTp7Ekg1s6t5/EzzjkxYUWX4amDNsrmfFfO/VEkQtWvY50x I6wLzZaAajYzpoqBi7Jd9K+nnpg2fPcjnCut4ykME1OwqQXWBD1kEn73s9QMRjbyDw UU8PlziOjpFjlQY6HMeuRpSrszm5qsmxHaTMvTJP/EJWQB4UuxaI/dS667rw0vPDMR BveOB4xGH9nfJM3l9svYsFItrJv64DtwB/+zCbDvlvkGqJncHqnbE51FmdQ8xmPhKu 2+X2KQf7CWAgynr1AHbZx53VnsazeT/sHQ1EBG6vD6P+b7L0WgckPbu/dWPYOZlEE6 RUGmy2YSQVflw== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10011401.me.com (Postfix) with ESMTPSA id AD9D534BA66B; Thu, 9 Jan 2025 13:29:09 +0000 (UTC) From: Zijun Hu Date: Thu, 09 Jan 2025 21:27:03 +0800 Subject: [PATCH v4 12/14] of: reserved-memory: Move an assignment to effective place in __reserved_mem_alloc_size() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250109-of_core_fix-v4-12-db8a72415b8c@quicinc.com> References: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> In-Reply-To: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> To: Rob Herring , Saravana Kannan , Maxime Ripard , Robin Murphy , Grant Likely , Marc Zyngier , Andreas Herrmann , Marek Szyprowski , Catalin Marinas , Mike Rapoport , Oreoluwa Babatunde Cc: Zijun Hu , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-GUID: JmDjGT6FCLuj8cC5Dk92dUhyoqg9vULs X-Proofpoint-ORIG-GUID: JmDjGT6FCLuj8cC5Dk92dUhyoqg9vULs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-09_05,2025-01-09_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=774 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2501090108 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu The assignment '@base =3D 0' in __reserved_mem_alloc_size() is meaningless since @base was already initialized to 0. Move the assignment to effective and proper place. Signed-off-by: Zijun Hu --- drivers/of/of_reserved_mem.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index e2da88d7706ab3c208386e29f31350178e67cd14..75e819f66a56139a800dba5e2e0= 044d0bbeb065e 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -441,13 +441,12 @@ static int __init __reserved_mem_alloc_size(unsigned = long node, const char *unam return -EINVAL; } =20 - base =3D 0; - while (len > 0) { start =3D dt_mem_next_cell(dt_root_addr_cells, &prop); end =3D start + dt_mem_next_cell(dt_root_size_cells, &prop); =20 + base =3D 0; ret =3D __reserved_mem_alloc_in_range(size, align, start, end, nomap, &base); if (ret =3D=3D 0) { --=20 2.34.1 From nobody Mon Feb 9 03:43:09 2026 Received: from pv50p00im-zteg10011401.me.com (pv50p00im-zteg10011401.me.com [17.58.6.41]) (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 2A95A219A7A for ; Thu, 9 Jan 2025 13:29:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429362; cv=none; b=OoQLnrvpeGmDtdwXUERs/BS/7z4QRhxb2A0UnlzsA+aLzNdo1Lut+8qwRBjALdxM6bfLgYD/6ImjTUc01IoZlrJ5CplW5mwhOe4vyOIcq8uL0hBez8L811KhEZwvnt0Q2HSPHBy/n4uqEa0rCq9c0ABU89V98lx4Mn1MlNLYULE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429362; c=relaxed/simple; bh=oc3D/zyp8WbDAwGnOMBcml77KnzpNLLUfFEut8L7u5o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tWldHVXLyTnqZF9x9yduEZ5lpaU+MBAx2fbrXNNXoYQWyV00szjSval3iyzHcg6Q8l3JiytffMwQCF4zgK53mEk9f04jIWWWUXCCcE3YzDZfsAVQeZZ9Ug3lXsIiOZtASU3HDO/jPqk9b2vk1NSpiJGV97I1mJuBpZmznb5D1mM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=c263AZTP; arc=none smtp.client-ip=17.58.6.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="c263AZTP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1736429360; bh=VttlFKzBqiDNNHrHSBO1fbls46nGnHCUvDday93lNP8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=c263AZTPQJhazc6SRZAM2Z9Wp9dmXEDlTLU/U2Qu1EWuXV3vgZgivJUWI/I8nTmlM TrfLoOrBG1w/ZVG/NITduTZn+okhKLxhETpDdyhtSNvmhrHRTdqecAw/t0cTSZ4q8r 0sPh9NowfXVQ7+orDdlG77WcW6PkCxNk56Uoi42WdvCn4ZlWFLBFOEQLclMYGITV6Y agon/GNpiiP/ddyCGi7QabEQvYcahsEm5+Eknr8Mj1MbqSs8f+DLNMEhkb6K6QwtMc RMFOz855XlnyQDxdv+zNl93AgaZlKnlWzgZe6S4ZxpgbeXIH4era1PJ7vciNXomEYf oPGz2AHM7Bqlg== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10011401.me.com (Postfix) with ESMTPSA id 5DA4434BAA7B; Thu, 9 Jan 2025 13:29:15 +0000 (UTC) From: Zijun Hu Date: Thu, 09 Jan 2025 21:27:04 +0800 Subject: [PATCH v4 13/14] of/fdt: Check fdt_get_mem_rsv() error in early_init_fdt_scan_reserved_mem() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250109-of_core_fix-v4-13-db8a72415b8c@quicinc.com> References: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> In-Reply-To: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> To: Rob Herring , Saravana Kannan , Maxime Ripard , Robin Murphy , Grant Likely , Marc Zyngier , Andreas Herrmann , Marek Szyprowski , Catalin Marinas , Mike Rapoport , Oreoluwa Babatunde Cc: Zijun Hu , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-GUID: SW_zWMny4wV80efwZibSlmux6H1NzeN0 X-Proofpoint-ORIG-GUID: SW_zWMny4wV80efwZibSlmux6H1NzeN0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-09_05,2025-01-09_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2501090108 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu early_init_fdt_scan_reserved_mem() invoks fdt_get_mem_rsv(), and it will use uninitialized variables @base and @size once the callee suffers error. Fix by checking fdt_get_mem_rsv() error as other callers do. Signed-off-by: Zijun Hu --- drivers/of/fdt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 4b1e9f101ce34d7212cc8de99c7e7761a2636866..c93a99d4a1e08c0d4cccf9e5ae1= 6f7e4950ee801 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -497,6 +497,7 @@ static void __init fdt_reserve_elfcorehdr(void) void __init early_init_fdt_scan_reserved_mem(void) { int n; + int res; u64 base, size; =20 if (!initial_boot_params) @@ -507,7 +508,11 @@ void __init early_init_fdt_scan_reserved_mem(void) =20 /* Process header /memreserve/ fields */ for (n =3D 0; ; n++) { - fdt_get_mem_rsv(initial_boot_params, n, &base, &size); + res =3D fdt_get_mem_rsv(initial_boot_params, n, &base, &size); + if (res) { + pr_err("Invalid memory reservation block index %d\n", n); + break; + } if (!size) break; memblock_reserve(base, size); --=20 2.34.1 From nobody Mon Feb 9 03:43:09 2026 Received: from pv50p00im-zteg10011401.me.com (pv50p00im-zteg10011401.me.com [17.58.6.41]) (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 2DB20219A9F for ; Thu, 9 Jan 2025 13:29:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429369; cv=none; b=ttmWPI0oMnlDq0+8Xc6RF/Ryzp5bHf4XhQsDCYP42MIW7nzo0OJeFKoaQS+P6FPF8y2sElQLYb7V0cXC1cOJldPC2tZLht6Yhzp1NjPPfbmViA/bm3oTlIwK6wSsh0NGff70VgGaxaDv2YQblz6czuLLiuq9EvSzc1N4NeXy5AY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429369; c=relaxed/simple; bh=psKAXNfWMkbLuX2WW3Qdc2tcwLQrqwBHOlIebl09gBA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=C7v4ShLy/n3jWh6p2wytNEgXZUwa9724t5ecf/+6gOySf0aFr/GxuGwp9bzOBJ8b1iKzIUa3WBWpFHJONiGzG/TSpuKJtbYapjjTDAtYvx6JVyeo+UX0MHMU6Rof2aCq/InHQljw/43iAywx8y4+PU3vFebomY9MWfcNZAYCs6U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=Z+XkuKxM; arc=none smtp.client-ip=17.58.6.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="Z+XkuKxM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1736429366; bh=t46Kq8JuBMjqD2GMAPFOubmxphOD1VWA7qYalmBy6T4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To: x-icloud-hme; b=Z+XkuKxMNMxtZFUq/KfukAB5D05jZwf0aWOEqjgpRYVnh+sHYcypx5/pGk9UVdakQ nPZfIgh0+GjL16Uw0PXVtgqmPsIlW8ZvJ9yPSuP60TK9dOgPmckqB+2vnEjHNSSQHW DxXxyRs+C3hiJBHOpjzqVdcIFuDdvAnkZGbad3/GzgHWe/ufXNewEHDlVeU39i9Lxl m+DLEL0MnAcNwjK0yxMpFeHpyfc49YpGhyKsLt2xhIAvqKcuH1hYnPiFJ5hgJuSH38 PZS7vtcWjuva2acoweH8Zh8Al3MQaoI1zWIPdwPddC3LwBe9hFxcqBtzXcP2+wUU9f HUorP41tW4qkA== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-zteg10011401.me.com (Postfix) with ESMTPSA id 7C5DF34BAAE8; Thu, 9 Jan 2025 13:29:21 +0000 (UTC) From: Zijun Hu Date: Thu, 09 Jan 2025 21:27:05 +0800 Subject: [PATCH v4 14/14] of: Improve __of_add_property_sysfs() readability Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250109-of_core_fix-v4-14-db8a72415b8c@quicinc.com> References: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> In-Reply-To: <20250109-of_core_fix-v4-0-db8a72415b8c@quicinc.com> To: Rob Herring , Saravana Kannan , Maxime Ripard , Robin Murphy , Grant Likely , Marc Zyngier , Andreas Herrmann , Marek Szyprowski , Catalin Marinas , Mike Rapoport , Oreoluwa Babatunde Cc: Zijun Hu , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.2 X-Proofpoint-GUID: qVAveBVSFTC5AwsLhX5zD_O3HrdYoxhC X-Proofpoint-ORIG-GUID: qVAveBVSFTC5AwsLhX5zD_O3HrdYoxhC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-09_05,2025-01-09_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=909 clxscore=1015 malwarescore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2501090108 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu __of_add_property_sysfs() hard codes string "security-" length as 9, but that is not obvious for readers. Improve its readability by using strlen(). Signed-off-by: Zijun Hu --- drivers/of/kobj.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c index aa887166f0d21030d620d43c864ca76cde1c6d05..44bfe50c6ea6503e3940578de1d= fc7fe0583dfb3 100644 --- a/drivers/of/kobj.c +++ b/drivers/of/kobj.c @@ -62,10 +62,11 @@ static const char *safe_name(const struct kobject *kobj= , const char *orig_name) =20 int __of_add_property_sysfs(struct device_node *np, struct property *pp) { + const char *security_prefix =3D "security-"; int rc; =20 /* Important: Don't leak passwords */ - bool secure =3D strncmp(pp->name, "security-", 9) =3D=3D 0; + bool secure =3D strncmp(pp->name, security_prefix, strlen(security_prefix= )) =3D=3D 0; =20 if (!IS_ENABLED(CONFIG_SYSFS)) return 0; --=20 2.34.1