public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC v2] of: property: Fix potential firmware node reference's argument count got out of range
@ 2025-01-14 15:51 Zijun Hu
  2025-01-14 17:01 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Zijun Hu @ 2025-01-14 15:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Rob Herring (Arm),
	Len Brown, Andy Shevchenko, Daniel Scally, Heikki Krogerus,
	Sakari Ailus
  Cc: Zijun Hu, linux-acpi, linux-kernel, Zijun Hu

From: Zijun Hu <quic_zijuhu@quicinc.com>

Currently, the following two macros have different values:

// The maximal argument count for firmware node reference
 #define NR_FWNODE_REFERENCE_ARGS	8
// The maximal argument count for OF node reference
 #define MAX_PHANDLE_ARGS 16

But of_fwnode_get_reference_args() directly assigns OF node
reference argument count @of_args.args_count to frimware
@args->nargs, and may cause firmware node reference argument
count @of_args.args_count got out of range, namely, in [9, 16].

Fix by increasing NR_FWNODE_REFERENCE_ARGS to 16 to meet OF requirement.

Fixes: 3e3119d3088f ("device property: Introduce fwnode_property_get_reference_args")
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
May remove MAX_PHANDLE_ARGS and use NR_FWNODE_REFERENCE_ARGS instead later.
---
Changes in v2:
- Increase macro @NR_FWNODE_REFERENCE_ARGS to align with @MAX_PHANDLE_ARGS.
- Correct fix tag and send as RFC patch.
- Link to v1: https://lore.kernel.org/r/20250109-of_core_fix-v4-7-db8a72415b8c@quicinc.com
---
 include/linux/fwnode.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 0731994b9d7c832cae8a30063f3a64194e4f19aa..6fa0a268d53827a376d7f258c6194a2a088e4325 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -91,7 +91,7 @@ struct fwnode_endpoint {
 #define SWNODE_GRAPH_PORT_NAME_FMT		"port@%u"
 #define SWNODE_GRAPH_ENDPOINT_NAME_FMT		"endpoint@%u"
 
-#define NR_FWNODE_REFERENCE_ARGS	8
+#define NR_FWNODE_REFERENCE_ARGS	16
 
 /**
  * struct fwnode_reference_args - Fwnode reference with additional arguments

---
base-commit: c141ecc3cecd764799e17c8251026336cab86800
change-id: 20250114-fix_arg_count-73feae90fccb

Best regards,
-- 
Zijun Hu <quic_zijuhu@quicinc.com>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH RFC v2] of: property: Fix potential firmware node reference's argument count got out of range
  2025-01-14 15:51 [PATCH RFC v2] of: property: Fix potential firmware node reference's argument count got out of range Zijun Hu
@ 2025-01-14 17:01 ` Andy Shevchenko
  2025-01-15 13:43   ` Zijun Hu
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2025-01-14 17:01 UTC (permalink / raw)
  To: Zijun Hu
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Rob Herring (Arm),
	Len Brown, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	linux-acpi, linux-kernel, Zijun Hu

On Tue, Jan 14, 2025 at 11:51:13PM +0800, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.com>
> 
> Currently, the following two macros have different values:
> 
> // The maximal argument count for firmware node reference
>  #define NR_FWNODE_REFERENCE_ARGS	8
> // The maximal argument count for OF node reference
>  #define MAX_PHANDLE_ARGS 16
> 
> But of_fwnode_get_reference_args() directly assigns OF node
> reference argument count @of_args.args_count to frimware

firmware

> @args->nargs, and may cause firmware node reference argument
> count @of_args.args_count got out of range, namely, in [9, 16].
> 
> Fix by increasing NR_FWNODE_REFERENCE_ARGS to 16 to meet OF requirement.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH RFC v2] of: property: Fix potential firmware node reference's argument count got out of range
  2025-01-14 17:01 ` Andy Shevchenko
@ 2025-01-15 13:43   ` Zijun Hu
  0 siblings, 0 replies; 3+ messages in thread
From: Zijun Hu @ 2025-01-15 13:43 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Rob Herring (Arm),
	Len Brown, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	linux-acpi, linux-kernel, Zijun Hu

On 2025/1/15 01:01, Andy Shevchenko wrote:
>> But of_fwnode_get_reference_args() directly assigns OF node
>> reference argument count @of_args.args_count to frimware
> firmware

Thank you Andy for comments.
will correct this error when send next formal revision (^^).



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-15 13:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-14 15:51 [PATCH RFC v2] of: property: Fix potential firmware node reference's argument count got out of range Zijun Hu
2025-01-14 17:01 ` Andy Shevchenko
2025-01-15 13:43   ` Zijun Hu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox