[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for-4.19(?)] xen/arm: bootfdt: Fix device tree memory node probing
Hi Michal,
On 27/06/2024 13:01, Michal Orzel wrote:
+/*
+ * Check if a node is a proper /memory node according to Devicetree
+ * Specification v0.4, chapter 3.4.
+ */
+static bool __init device_tree_is_memory_node(const void *fdt, int node,
+ int depth)
+{
+ const char *type;
+ int len;
+
+ if ( depth != 1 )
+ return false;
+
+ if ( !device_tree_node_matches(fdt, node, "memory") )
+ return false;
+
+ type = fdt_getprop(fdt, node, "device_type", &len);
+ if ( !type )
+ return false;
+
+ if ( (len <= 0) || strcmp(type, "memory") )
I would consider to use strncmp() to avoid relying on the property to be
well-formed (i.e. nul-terminated).
Are you sure? AFAIR, libfdt returns NULL and -FDT_ERR_TRUNCATED as len if a
string is non null terminated.
I can't find such code in path. Do you have any pointer?
I checked and I cannot find such code either. I made the wrong assumption
thinking that fdt_getprop can only work with strings.
Therefore, I'm ok with changing s/strcmp/strncmp/ for hardening. Shall I respin
the patch marking it as for-4.20?
Sorry this e-mail fell through the cracks. Yes please. I need to create
a branch to collect all simple patches for 4.20.
Cheers,
--
Julien Grall
|