* [PATCH v2 0/7] of: fix bugs and improve codes
@ 2024-12-16 0:40 Zijun Hu
2024-12-16 0:40 ` [PATCH v2 1/7] of: Fix API of_find_node_opts_by_path() finding OF device node failure Zijun Hu
` (6 more replies)
0 siblings, 7 replies; 13+ messages in thread
From: Zijun Hu @ 2024-12-16 0:40 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Maxime Ripard, Robin Murphy,
Grant Likely
Cc: Zijun Hu, devicetree, linux-kernel, Zijun Hu, stable
This patch series is to fix bugs and improve codes for drivers/of/*.
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
Changes in v2:
- Drop applied/conflict/TBD patches.
- Correct based on Rob's comments.
- Link to v1: https://lore.kernel.org/r/20241206-of_core_fix-v1-0-dc28ed56bec3@quicinc.com
---
Zijun Hu (7):
of: Fix API of_find_node_opts_by_path() finding OF device node failure
of: unittest: Add a test case for API of_find_node_opts_by_path()
of: Correct child specifier used as input of the 2nd nexus node
of: Exchange implementation between of_property_present() and of_property_read_bool()
of: Fix available buffer size calculating error in API of_device_uevent_modalias()
of: Fix potential wrong MODALIAS uevent value
of: Do not expose of_alias_scan() and correct its comments
drivers/of/base.c | 13 +++---
drivers/of/device.c | 33 +++++++---------
drivers/of/module.c | 103 +++++++++++++++++++++++++++++-------------------
drivers/of/of_private.h | 2 +
drivers/of/pdt.c | 2 +
drivers/of/unittest.c | 9 +++++
include/linux/of.h | 29 +++++++-------
7 files changed, 109 insertions(+), 82 deletions(-)
---
base-commit: 0f7ca6f69354e0c3923bbc28c92d0ecab4d50a3e
change-id: 20241206-of_core_fix-dc3021a06418
Best regards,
--
Zijun Hu <quic_zijuhu@quicinc.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 1/7] of: Fix API of_find_node_opts_by_path() finding OF device node failure
2024-12-16 0:40 [PATCH v2 0/7] of: fix bugs and improve codes Zijun Hu
@ 2024-12-16 0:40 ` Zijun Hu
2024-12-16 0:40 ` [PATCH v2 2/7] of: unittest: Add a test case for API of_find_node_opts_by_path() Zijun Hu
` (5 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Zijun Hu @ 2024-12-16 0:40 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Maxime Ripard, Robin Murphy,
Grant Likely
Cc: Zijun Hu, devicetree, linux-kernel, Zijun Hu, stable
From: Zijun Hu <quic_zijuhu@quicinc.com>
API of_find_node_opts_by_path() fails to find OF device node when its
@path parameter have pattern below:
"alias-name/node-name-1/.../node-name-N:options".
The reason is that alias name length calculated by the API is wrong, as
explained by example below:
"testcase-alias/phandle-tests/consumer-a:testaliasoption".
^ ^ ^
0 14 39
The right length of alias 'testcase-alias' is 14, but the result worked
out by the API is 39 which is obvious wrong.
Fix by using index of either '/' or ':' as the length who comes earlier.
Fixes: 75c28c09af99 ("of: add optional options parameter to of_find_node_by_path()")
Cc: stable@vger.kernel.org
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/of/base.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index d2d021f7cf5809b6e765c14911bda0df55f36ca9..bf18d5997770eb81e47e749198dd505a35203d10 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -893,10 +893,10 @@ struct device_node *of_find_node_opts_by_path(const char *path, const char **opt
/* The path could begin with an alias */
if (*path != '/') {
int len;
- const char *p = separator;
+ const char *p = strchrnul(path, '/');
- if (!p)
- p = strchrnul(path, '/');
+ if (separator && separator < p)
+ p = separator;
len = p - path;
/* of_aliases must not be NULL */
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 2/7] of: unittest: Add a test case for API of_find_node_opts_by_path()
2024-12-16 0:40 [PATCH v2 0/7] of: fix bugs and improve codes Zijun Hu
2024-12-16 0:40 ` [PATCH v2 1/7] of: Fix API of_find_node_opts_by_path() finding OF device node failure Zijun Hu
@ 2024-12-16 0:40 ` Zijun Hu
2024-12-16 19:23 ` Rob Herring
2024-12-16 0:40 ` [PATCH v2 3/7] of: Correct child specifier used as input of the 2nd nexus node Zijun Hu
` (4 subsequent siblings)
6 siblings, 1 reply; 13+ messages in thread
From: Zijun Hu @ 2024-12-16 0:40 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Maxime Ripard, Robin Murphy,
Grant Likely
Cc: Zijun Hu, devicetree, linux-kernel, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
To test of_find_node_opts_by_path() take @path argument with pattern:
"alias-name/node-name-1/.../node-name-N:options", for example:
"testcase-alias/phandle-tests/consumer-a:testaliasoption"
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/of/unittest.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index daf9a2dddd7e0dbc680f708496b6dce6d23999cf..ed343509505f536436f8457bd200ccc323acffdf 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -161,6 +161,15 @@ static void __init of_unittest_find_node_by_name(void)
"option alias path test, subcase #1 failed\n");
of_node_put(np);
+ np = of_find_node_opts_by_path("testcase-alias/phandle-tests/consumer-a:testaliasoption",
+ &options);
+ name = kasprintf(GFP_KERNEL, "%pOF", np);
+ unittest(np && name && !strcmp("/testcase-data/phandle-tests/consumer-a", name) &&
+ !strcmp("testaliasoption", options),
+ "option alias path test, subcase #2 failed\n");
+ of_node_put(np);
+ kfree(name);
+
np = of_find_node_opts_by_path("testcase-alias:testaliasoption", NULL);
unittest(np, "NULL option alias path test failed\n");
of_node_put(np);
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 3/7] of: Correct child specifier used as input of the 2nd nexus node
2024-12-16 0:40 [PATCH v2 0/7] of: fix bugs and improve codes Zijun Hu
2024-12-16 0:40 ` [PATCH v2 1/7] of: Fix API of_find_node_opts_by_path() finding OF device node failure Zijun Hu
2024-12-16 0:40 ` [PATCH v2 2/7] of: unittest: Add a test case for API of_find_node_opts_by_path() Zijun Hu
@ 2024-12-16 0:40 ` Zijun Hu
2024-12-16 0:40 ` [PATCH v2 4/7] of: Exchange implementation between of_property_present() and of_property_read_bool() Zijun Hu
` (3 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Zijun Hu @ 2024-12-16 0:40 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Maxime Ripard, Robin Murphy,
Grant Likely
Cc: Zijun Hu, devicetree, linux-kernel, Zijun Hu, stable
From: Zijun Hu <quic_zijuhu@quicinc.com>
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=<...>
Nexus_1's output arg_2 should be used as input of Nexus_2, but the API
wrongly uses arg_2' instead which != 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 <quic_zijuhu@quicinc.com>
---
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..969b99838655534915882abe358814d505c6f748 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1536,7 +1536,6 @@ int of_parse_phandle_with_args_map(const struct device_node *np,
* specifier into the out_args structure, keeping the
* bits specified in <list>-map-pass-thru.
*/
- match_array = map - new_size;
for (i = 0; i < new_size; i++) {
__be32 val = *(map - new_size + i);
@@ -1545,6 +1544,7 @@ int of_parse_phandle_with_args_map(const struct device_node *np,
val |= cpu_to_be32(out_args->args[i]) & pass[i];
}
+ initial_match_array[i] = val;
out_args->args[i] = be32_to_cpu(val);
}
out_args->args_count = list_size = new_size;
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 4/7] of: Exchange implementation between of_property_present() and of_property_read_bool()
2024-12-16 0:40 [PATCH v2 0/7] of: fix bugs and improve codes Zijun Hu
` (2 preceding siblings ...)
2024-12-16 0:40 ` [PATCH v2 3/7] of: Correct child specifier used as input of the 2nd nexus node Zijun Hu
@ 2024-12-16 0:40 ` Zijun Hu
2024-12-16 0:40 ` [PATCH v2 5/7] of: Fix available buffer size calculating error in API of_device_uevent_modalias() Zijun Hu
` (2 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Zijun Hu @ 2024-12-16 0:40 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Maxime Ripard, Robin Murphy,
Grant Likely
Cc: Zijun Hu, devicetree, linux-kernel, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
of_property_present() is to check if a property is present or not,
and it should be applicable for all kinds of property, but it calls
of_property_read_bool() to implement the function, so narrows its
property scope to only bool type.
Fix by exchanging implementation, namely, changing call chain from:
of_property_present() -> of_property_read_bool() -> of_find_property()
to :
of_property_read_bool() -> of_property_present() -> of_find_property()
which looks more logical as well.
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
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 f921786cb8ac782286ed5ff4425a35668204d050..7b0da8d352dffd8b872998903282119b6164a5bc 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -1243,17 +1243,16 @@ static inline int of_property_read_string_index(const struct device_node *np,
}
/**
- * 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 = of_find_property(np, propname, NULL);
@@ -1261,17 +1260,19 @@ static inline bool of_property_read_bool(const struct device_node *np,
}
/**
- * 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);
}
/**
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 5/7] of: Fix available buffer size calculating error in API of_device_uevent_modalias()
2024-12-16 0:40 [PATCH v2 0/7] of: fix bugs and improve codes Zijun Hu
` (3 preceding siblings ...)
2024-12-16 0:40 ` [PATCH v2 4/7] of: Exchange implementation between of_property_present() and of_property_read_bool() Zijun Hu
@ 2024-12-16 0:40 ` Zijun Hu
2024-12-16 0:40 ` [PATCH v2 6/7] of: Fix potential wrong MODALIAS uevent value Zijun Hu
2024-12-16 0:40 ` [PATCH v2 7/7] of: Do not expose of_alias_scan() and correct its comments Zijun Hu
6 siblings, 0 replies; 13+ messages in thread
From: Zijun Hu @ 2024-12-16 0:40 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Maxime Ripard, Robin Murphy,
Grant Likely
Cc: Zijun Hu, devicetree, linux-kernel, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
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=".
Fixes: dd27dcda37f0 ("of/device: merge of_device_uevent")
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
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..f24c19e7aba8e01656f503ae328a4e08aab5a5f3 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;
if ((!dev) || (!dev->of_node) || dev->of_node_reused)
return -ENODEV;
@@ -265,13 +266,18 @@ int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *
if (add_uevent_var(env, "MODALIAS="))
return -ENOMEM;
- sl = 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 = env->buflen - 1;
+ sl = of_modalias(dev->of_node, &env->buf[pos],
+ sizeof(env->buf) - pos);
if (sl < 0)
return sl;
- if (sl >= (sizeof(env->buf) - env->buflen))
+ if (sl >= (sizeof(env->buf) - pos))
return -ENOMEM;
- env->buflen += sl;
+ env->buflen = pos + sl + 1;
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 6/7] of: Fix potential wrong MODALIAS uevent value
2024-12-16 0:40 [PATCH v2 0/7] of: fix bugs and improve codes Zijun Hu
` (4 preceding siblings ...)
2024-12-16 0:40 ` [PATCH v2 5/7] of: Fix available buffer size calculating error in API of_device_uevent_modalias() Zijun Hu
@ 2024-12-16 0:40 ` Zijun Hu
2024-12-16 3:42 ` kernel test robot
` (2 more replies)
2024-12-16 0:40 ` [PATCH v2 7/7] of: Do not expose of_alias_scan() and correct its comments Zijun Hu
6 siblings, 3 replies; 13+ messages in thread
From: Zijun Hu @ 2024-12-16 0:40 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Maxime Ripard, Robin Murphy,
Grant Likely
Cc: Zijun Hu, devicetree, linux-kernel, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
API of_device_uevent_modalias() makes uevent "MODALIAS=ITS_VALUE" in two
steps, namely, produces "MODALIAS=" with add_uevent_var() fistly, then
remainning "ITS_VALUE" with of_modalias() finally, and that may result
in various wrong uevents as explained below:
"MODALIAS=\0" // @env->buf is full after the 1st step.
"MODALIAS=ITS_\0" // @env->buf is not enough during 2nd step.
"MODALIAS=ITS_VAR=VAR_VALUE\0" // another uevent "VAR=VAR_VALUE" comes.
The API depends on uevent internal design, so is not good practice as well.
Fix by:
1) Respin the callee of_modalias() with new prototype which is friendly
with its callers.
2) Invoke add_uevent_var() to make the whole MODALIAS uevent.
3) Adapt new of_modalias() for its other callers.
BTW, there are no external callers of of_modalias() now.
Closes: https://lore.kernel.org/all/CAL_JsqL+CRmCQMzcF4-A-PRBrCsfK8nduJtOO=RrsDtCUUR7og@mail.gmail.com
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/of/device.c | 39 +++++++-------------
drivers/of/module.c | 103 +++++++++++++++++++++++++++++++---------------------
include/linux/of.h | 5 +--
3 files changed, 78 insertions(+), 69 deletions(-)
diff --git a/drivers/of/device.c b/drivers/of/device.c
index f24c19e7aba8e01656f503ae328a4e08aab5a5f3..6355707c200da9ced354132528adbcce24121247 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -195,19 +195,18 @@ EXPORT_SYMBOL(of_device_get_match_data);
ssize_t of_device_modalias(struct device *dev, char *str, ssize_t len)
{
ssize_t sl;
+ char *ptr __free(kfree) = NULL;
if (!dev || !dev->of_node || dev->of_node_reused)
return -ENODEV;
- sl = of_modalias(dev->of_node, str, len - 2);
- if (sl < 0)
- return sl;
- if (sl > len - 2)
+ ptr = of_modalias(dev->of_node, &sl);
+ if (IS_ERR(ptr))
+ return PTR_ERR(no_free_ptr(ptr));
+ if (sl + 2 > len)
return -ENOMEM;
- str[sl++] = '\n';
- str[sl] = 0;
- return sl;
+ return snprintf(str, len, "%s\n", ptr);
}
EXPORT_SYMBOL_GPL(of_device_modalias);
@@ -256,30 +255,20 @@ EXPORT_SYMBOL_GPL(of_device_uevent);
int of_device_uevent_modalias(const struct device *dev, struct kobj_uevent_env *env)
{
- int sl;
- int pos;
+ int ret;
+ char *ptr;
if ((!dev) || (!dev->of_node) || dev->of_node_reused)
return -ENODEV;
- /* Devicetree modalias is tricky, we add it in 2 steps */
- if (add_uevent_var(env, "MODALIAS="))
- return -ENOMEM;
+ ptr = of_modalias(dev->of_node, NULL);
+ if (IS_ERR(ptr))
+ return PTR_ERR(ptr);
- /*
- * @env->buflen is pointing to the char after '\0' now
- * override the '\0' to save MODALIAS value.
- */
- pos = env->buflen - 1;
- sl = of_modalias(dev->of_node, &env->buf[pos],
- sizeof(env->buf) - pos);
- if (sl < 0)
- return sl;
- if (sl >= (sizeof(env->buf) - pos))
- return -ENOMEM;
- env->buflen = pos + sl + 1;
+ ret = add_uevent_var(env, "MODALIAS=%s", ptr);
- return 0;
+ kfree(ptr);
+ return ret;
}
EXPORT_SYMBOL_GPL(of_device_uevent_modalias);
diff --git a/drivers/of/module.c b/drivers/of/module.c
index 1e735fc130ad3ea9046f08bfab2cc9a07914e633..03a2b1b381e5b353b6699dac183c03186afb0486 100644
--- a/drivers/of/module.c
+++ b/drivers/of/module.c
@@ -8,71 +8,92 @@
#include <linux/slab.h>
#include <linux/string.h>
-ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len)
+/*
+ * of_modalias - get MODALIAS string value for a OF device node
+ * @np: the OF device node
+ * @lenp: MODALIAS string length returned if set, exclude '\0'
+ *
+ * This function gets MODALIAS value for a device node.
+ *
+ * Returns MODALIAS string on success, or ERR_PTR() on error.
+ *
+ * Note: please kfree successful return value afer using it.
+ */
+char *of_modalias(const struct device_node *np, ssize_t *lenp)
{
const char *compat;
char *c;
struct property *p;
ssize_t csize;
ssize_t tsize;
+ char *str = NULL;
+ ssize_t len = 0;
+ ssize_t pos = 0;
+ int counting = 1;
+
+ if (lenp)
+ *lenp = 0;
/*
- * Prevent a kernel oops in vsnprintf() -- it only allows passing a
- * NULL ptr when the length is also 0. Also filter out the negative
- * lengths...
+ * Two cycles controlled by @counting, the fist cycle counts
+ * chars, the second saves chars.
*/
- if ((len > 0 && !str) || len < 0)
- return -EINVAL;
+ do {
+ /* Name & Type */
+ /* %p eats all alphanum characters, so %c must be used here */
+ csize = snprintf(str + pos, len - pos, "of:N%pOFn%c%s", np, 'T',
+ of_node_get_device_type(np));
+ if (counting)
+ tsize = csize;
+ else
+ pos += csize;
- /* Name & Type */
- /* %p eats all alphanum characters, so %c must be used here */
- csize = snprintf(str, len, "of:N%pOFn%c%s", np, 'T',
- of_node_get_device_type(np));
- tsize = csize;
- if (csize >= len)
- csize = len > 0 ? len - 1 : 0;
- len -= csize;
- str += csize;
+ of_property_for_each_string(np, "compatible", p, compat) {
+ csize = snprintf(str + pos, len - pos, "C%s", compat);
+ if (counting) {
+ tsize += csize;
+ continue;
+ }
- of_property_for_each_string(np, "compatible", p, compat) {
- csize = snprintf(str, len, "C%s", compat);
- tsize += csize;
- if (csize >= len)
- continue;
- for (c = str; c; ) {
- c = strchr(c, ' ');
- if (c)
- *c++ = '_';
+ for (c = str + pos; c; ) {
+ c = strchr(c, ' ');
+ if (c)
+ *c++ = '_';
+ }
+ pos += csize;
}
- len -= csize;
- str += csize;
- }
- return tsize;
+ if (counting) {
+ /* Include '\0' of MODALIAS string. */
+ len = tsize + 1;
+ /* MODALIAS value is too long */
+ if (unlikely(len > 2048))
+ return ERR_PTR(-EINVAL);
+
+ str = kmalloc(len, GFP_KERNEL);
+ if (!str)
+ return ERR_PTR(-ENOMEM);
+ }
+
+ } while (counting--);
+
+ if (lenp)
+ *lenp = tsize;
+ return str;
}
int of_request_module(const struct device_node *np)
{
char *str;
- ssize_t size;
int ret;
if (!np)
return -ENODEV;
- size = of_modalias(np, NULL, 0);
- if (size < 0)
- return size;
-
- /* Reserve an additional byte for the trailing '\0' */
- size++;
-
- str = kmalloc(size, GFP_KERNEL);
- if (!str)
- return -ENOMEM;
+ str = of_modalias(np, NULL);
+ if (IS_ERR(str))
+ return PTR_ERR(str);
- of_modalias(np, str, size);
- str[size - 1] = '\0';
ret = request_module(str);
kfree(str);
diff --git a/include/linux/of.h b/include/linux/of.h
index 7b0da8d352dffd8b872998903282119b6164a5bc..2fcc12de4a9178276a24cd4d6c975495b9eb04a2 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -382,7 +382,7 @@ extern int of_count_phandle_with_args(const struct device_node *np,
const char *list_name, const char *cells_name);
/* module functions */
-extern ssize_t of_modalias(const struct device_node *np, char *str, ssize_t len);
+char *of_modalias(const struct device_node *np, ssize_t *lenp);
extern int of_request_module(const struct device_node *np);
/* phandle iterator functions */
@@ -762,8 +762,7 @@ static inline int of_count_phandle_with_args(const struct device_node *np,
return -ENOSYS;
}
-static inline ssize_t of_modalias(const struct device_node *np, char *str,
- ssize_t len)
+static inline char *of_modalias(const struct device_node *np, ssize_t *lenp)
{
return -ENODEV;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 7/7] of: Do not expose of_alias_scan() and correct its comments
2024-12-16 0:40 [PATCH v2 0/7] of: fix bugs and improve codes Zijun Hu
` (5 preceding siblings ...)
2024-12-16 0:40 ` [PATCH v2 6/7] of: Fix potential wrong MODALIAS uevent value Zijun Hu
@ 2024-12-16 0:40 ` Zijun Hu
6 siblings, 0 replies; 13+ messages in thread
From: Zijun Hu @ 2024-12-16 0:40 UTC (permalink / raw)
To: Rob Herring, Saravana Kannan, Maxime Ripard, Robin Murphy,
Grant Likely
Cc: Zijun Hu, devicetree, linux-kernel, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
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 <quic_zijuhu@quicinc.com>
---
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..5485307e2a3a3d3a216d271c60bdfc346dd38460 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1806,14 +1806,13 @@ static void of_alias_add(struct alias_prop *ap, struct device_node *np,
ap->alias, ap->stem, ap->id, np);
}
-/**
+/*
* 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 populates
- * 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..3433ccd330e84fd3a4b54638e0e922069757c8f0 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);
+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..f961aaa9b96cc4a31c39f42291e87b0007394ec5 100644
--- a/drivers/of/pdt.c
+++ b/drivers/of/pdt.c
@@ -21,6 +21,8 @@
static struct of_pdt_ops *of_pdt_prom_ops __initdata;
+void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align));
+
#if defined(CONFIG_SPARC)
unsigned int of_pdt_unique_id __initdata;
diff --git a/include/linux/of.h b/include/linux/of.h
index 2fcc12de4a9178276a24cd4d6c975495b9eb04a2..b43e8d5561332a10cee006b383d42822f28057e1 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -397,7 +397,6 @@ extern int of_phandle_iterator_args(struct of_phandle_iterator *it,
uint32_t *args,
int size);
-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);
--
2.34.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 6/7] of: Fix potential wrong MODALIAS uevent value
2024-12-16 0:40 ` [PATCH v2 6/7] of: Fix potential wrong MODALIAS uevent value Zijun Hu
@ 2024-12-16 3:42 ` kernel test robot
2024-12-16 3:52 ` kernel test robot
2024-12-16 7:02 ` kernel test robot
2 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2024-12-16 3:42 UTC (permalink / raw)
To: Zijun Hu, Rob Herring, Saravana Kannan, Maxime Ripard,
Robin Murphy, Grant Likely
Cc: oe-kbuild-all, Zijun Hu, devicetree, linux-kernel
Hi Zijun,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 0f7ca6f69354e0c3923bbc28c92d0ecab4d50a3e]
url: https://github.com/intel-lab-lkp/linux/commits/Zijun-Hu/of-Fix-API-of_find_node_opts_by_path-finding-OF-device-node-failure/20241216-084408
base: 0f7ca6f69354e0c3923bbc28c92d0ecab4d50a3e
patch link: https://lore.kernel.org/r/20241216-of_core_fix-v2-6-e69b8f60da63%40quicinc.com
patch subject: [PATCH v2 6/7] of: Fix potential wrong MODALIAS uevent value
config: x86_64-buildonly-randconfig-001-20241216 (https://download.01.org/0day-ci/archive/20241216/202412161157.HWxjPpzy-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241216/202412161157.HWxjPpzy-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412161157.HWxjPpzy-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from include/linux/irqdomain.h:36,
from include/linux/i2c.h:21,
from drivers/leds/leds-blinkm.c:11:
include/linux/of.h: In function 'of_modalias':
>> include/linux/of.h:764:16: warning: returning 'int' from a function with return type 'char *' makes pointer from integer without a cast [-Wint-conversion]
764 | return -ENODEV;
| ^
--
In file included from include/linux/irqdomain.h:36,
from include/linux/gpio/driver.h:9,
from drivers/leds/leds-pca955x.c:44:
include/linux/of.h: In function 'of_modalias':
>> include/linux/of.h:764:16: warning: returning 'int' from a function with return type 'char *' makes pointer from integer without a cast [-Wint-conversion]
764 | return -ENODEV;
| ^
drivers/leds/leds-pca955x.c: In function 'pca955x_probe':
drivers/leds/leds-pca955x.c:555:43: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Wformat-truncation=]
555 | "%d", i);
| ^~
drivers/leds/leds-pca955x.c:555:42: note: directive argument in the range [-2147483644, 2147483646]
555 | "%d", i);
| ^~~~
drivers/leds/leds-pca955x.c:554:33: note: 'snprintf' output between 2 and 12 bytes into a destination of size 8
554 | snprintf(default_label, sizeof(default_label),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
555 | "%d", i);
| ~~~~~~~~
--
In file included from drivers/leds/led-core.c:16:
include/linux/of.h: In function 'of_modalias':
>> include/linux/of.h:764:16: warning: returning 'int' from a function with return type 'char *' makes pointer from integer without a cast [-Wint-conversion]
764 | return -ENODEV;
| ^
drivers/leds/led-core.c: In function 'led_compose_name':
drivers/leds/led-core.c:551:78: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
551 | snprintf(led_classdev_name, LED_MAX_NAME_SIZE, "%s:%s",
| ^
drivers/leds/led-core.c:551:25: note: 'snprintf' output 2 or more bytes (assuming 65) into a destination of size 64
551 | snprintf(led_classdev_name, LED_MAX_NAME_SIZE, "%s:%s",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
552 | devicename, tmp_buf);
| ~~~~~~~~~~~~~~~~~~~~
vim +764 include/linux/of.h
bd69f73f2c81eed Grant Likely 2013-02-10 761
f1f6eae8bdfdfce Zijun Hu 2024-12-16 762 static inline char *of_modalias(const struct device_node *np, ssize_t *lenp)
bd7a7ed774afd1a Miquel Raynal 2023-04-04 763 {
bd7a7ed774afd1a Miquel Raynal 2023-04-04 @764 return -ENODEV;
bd7a7ed774afd1a Miquel Raynal 2023-04-04 765 }
bd7a7ed774afd1a Miquel Raynal 2023-04-04 766
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 6/7] of: Fix potential wrong MODALIAS uevent value
2024-12-16 0:40 ` [PATCH v2 6/7] of: Fix potential wrong MODALIAS uevent value Zijun Hu
2024-12-16 3:42 ` kernel test robot
@ 2024-12-16 3:52 ` kernel test robot
2024-12-16 7:02 ` kernel test robot
2 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2024-12-16 3:52 UTC (permalink / raw)
To: Zijun Hu, Rob Herring, Saravana Kannan, Maxime Ripard,
Robin Murphy, Grant Likely
Cc: llvm, oe-kbuild-all, Zijun Hu, devicetree, linux-kernel
Hi Zijun,
kernel test robot noticed the following build errors:
[auto build test ERROR on 0f7ca6f69354e0c3923bbc28c92d0ecab4d50a3e]
url: https://github.com/intel-lab-lkp/linux/commits/Zijun-Hu/of-Fix-API-of_find_node_opts_by_path-finding-OF-device-node-failure/20241216-084408
base: 0f7ca6f69354e0c3923bbc28c92d0ecab4d50a3e
patch link: https://lore.kernel.org/r/20241216-of_core_fix-v2-6-e69b8f60da63%40quicinc.com
patch subject: [PATCH v2 6/7] of: Fix potential wrong MODALIAS uevent value
config: x86_64-buildonly-randconfig-003-20241216 (https://download.01.org/0day-ci/archive/20241216/202412161149.xqUOFg3R-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241216/202412161149.xqUOFg3R-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412161149.xqUOFg3R-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
In file included from lib/genalloc.c:35:
>> include/linux/of.h:764:9: error: incompatible integer to pointer conversion returning 'int' from a function with result type 'char *' [-Wint-conversion]
764 | return -ENODEV;
| ^~~~~~~
In file included from lib/genalloc.c:37:
In file included from include/linux/platform_device.h:13:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/x86/include/asm/elf.h:10:
In file included from arch/x86/include/asm/ia32.h:7:
In file included from include/linux/compat.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:98:11: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
98 | return (set->sig[3] | set->sig[2] |
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/genalloc.c:37:
In file included from include/linux/platform_device.h:13:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/x86/include/asm/elf.h:10:
In file included from arch/x86/include/asm/ia32.h:7:
In file included from include/linux/compat.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:98:25: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
98 | return (set->sig[3] | set->sig[2] |
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/genalloc.c:37:
In file included from include/linux/platform_device.h:13:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/x86/include/asm/elf.h:10:
In file included from arch/x86/include/asm/ia32.h:7:
In file included from include/linux/compat.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:99:4: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
99 | set->sig[1] | set->sig[0]) == 0;
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/genalloc.c:37:
In file included from include/linux/platform_device.h:13:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/x86/include/asm/elf.h:10:
In file included from arch/x86/include/asm/ia32.h:7:
In file included from include/linux/compat.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:101:11: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
101 | return (set->sig[1] | set->sig[0]) == 0;
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/genalloc.c:37:
In file included from include/linux/platform_device.h:13:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/x86/include/asm/elf.h:10:
In file included from arch/x86/include/asm/ia32.h:7:
In file included from include/linux/compat.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:114:11: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
114 | return (set1->sig[3] == set2->sig[3]) &&
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/genalloc.c:37:
In file included from include/linux/platform_device.h:13:
In file included from include/linux/device.h:32:
--
In file included from lib/devres.c:9:
In file included from include/linux/of_address.h:6:
>> include/linux/of.h:764:9: error: incompatible integer to pointer conversion returning 'int' from a function with result type 'char *' [-Wint-conversion]
764 | return -ENODEV;
| ^~~~~~~
1 error generated.
--
In file included from lib/logic_pio.c:11:
>> include/linux/of.h:764:9: error: incompatible integer to pointer conversion returning 'int' from a function with result type 'char *' [-Wint-conversion]
764 | return -ENODEV;
| ^~~~~~~
In file included from lib/logic_pio.c:14:
In file included from include/linux/mm.h:1120:
In file included from include/linux/huge_mm.h:8:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:98:11: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
98 | return (set->sig[3] | set->sig[2] |
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/logic_pio.c:14:
In file included from include/linux/mm.h:1120:
In file included from include/linux/huge_mm.h:8:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:98:25: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
98 | return (set->sig[3] | set->sig[2] |
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/logic_pio.c:14:
In file included from include/linux/mm.h:1120:
In file included from include/linux/huge_mm.h:8:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:99:4: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
99 | set->sig[1] | set->sig[0]) == 0;
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/logic_pio.c:14:
In file included from include/linux/mm.h:1120:
In file included from include/linux/huge_mm.h:8:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:101:11: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
101 | return (set->sig[1] | set->sig[0]) == 0;
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/logic_pio.c:14:
In file included from include/linux/mm.h:1120:
In file included from include/linux/huge_mm.h:8:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:114:11: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
114 | return (set1->sig[3] == set2->sig[3]) &&
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/logic_pio.c:14:
In file included from include/linux/mm.h:1120:
In file included from include/linux/huge_mm.h:8:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:114:27: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
114 | return (set1->sig[3] == set2->sig[3]) &&
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/logic_pio.c:14:
In file included from include/linux/mm.h:1120:
In file included from include/linux/huge_mm.h:8:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:115:5: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
115 | (set1->sig[2] == set2->sig[2]) &&
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/logic_pio.c:14:
In file included from include/linux/mm.h:1120:
In file included from include/linux/huge_mm.h:8:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
--
In file included from lib/vsprintf.c:23:
In file included from include/linux/clk-provider.h:9:
>> include/linux/of.h:764:9: error: incompatible integer to pointer conversion returning 'int' from a function with result type 'char *' [-Wint-conversion]
764 | return -ENODEV;
| ^~~~~~~
In file included from lib/vsprintf.c:25:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/x86/include/asm/elf.h:10:
In file included from arch/x86/include/asm/ia32.h:7:
In file included from include/linux/compat.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:98:11: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
98 | return (set->sig[3] | set->sig[2] |
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/vsprintf.c:25:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/x86/include/asm/elf.h:10:
In file included from arch/x86/include/asm/ia32.h:7:
In file included from include/linux/compat.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:98:25: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
98 | return (set->sig[3] | set->sig[2] |
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/vsprintf.c:25:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/x86/include/asm/elf.h:10:
In file included from arch/x86/include/asm/ia32.h:7:
In file included from include/linux/compat.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:99:4: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
99 | set->sig[1] | set->sig[0]) == 0;
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/vsprintf.c:25:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/x86/include/asm/elf.h:10:
In file included from arch/x86/include/asm/ia32.h:7:
In file included from include/linux/compat.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:101:11: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
101 | return (set->sig[1] | set->sig[0]) == 0;
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/vsprintf.c:25:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/x86/include/asm/elf.h:10:
In file included from arch/x86/include/asm/ia32.h:7:
In file included from include/linux/compat.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:114:11: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
114 | return (set1->sig[3] == set2->sig[3]) &&
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/vsprintf.c:25:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/x86/include/asm/elf.h:10:
In file included from arch/x86/include/asm/ia32.h:7:
In file included from include/linux/compat.h:17:
In file included from include/linux/fs.h:33:
In file included from include/linux/percpu-rwsem.h:7:
In file included from include/linux/rcuwait.h:6:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:114:27: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
114 | return (set1->sig[3] == set2->sig[3]) &&
| ^ ~
arch/x86/include/asm/signal.h:24:2: note: array 'sig' declared here
24 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from lib/vsprintf.c:25:
In file included from include/linux/module.h:19:
..
vim +764 include/linux/of.h
bd69f73f2c81eed Grant Likely 2013-02-10 761
f1f6eae8bdfdfce Zijun Hu 2024-12-16 762 static inline char *of_modalias(const struct device_node *np, ssize_t *lenp)
bd7a7ed774afd1a Miquel Raynal 2023-04-04 763 {
bd7a7ed774afd1a Miquel Raynal 2023-04-04 @764 return -ENODEV;
bd7a7ed774afd1a Miquel Raynal 2023-04-04 765 }
bd7a7ed774afd1a Miquel Raynal 2023-04-04 766
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 6/7] of: Fix potential wrong MODALIAS uevent value
2024-12-16 0:40 ` [PATCH v2 6/7] of: Fix potential wrong MODALIAS uevent value Zijun Hu
2024-12-16 3:42 ` kernel test robot
2024-12-16 3:52 ` kernel test robot
@ 2024-12-16 7:02 ` kernel test robot
2 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2024-12-16 7:02 UTC (permalink / raw)
To: Zijun Hu, Rob Herring, Saravana Kannan, Maxime Ripard,
Robin Murphy, Grant Likely
Cc: oe-kbuild-all, Zijun Hu, devicetree, linux-kernel
Hi Zijun,
kernel test robot noticed the following build errors:
[auto build test ERROR on 0f7ca6f69354e0c3923bbc28c92d0ecab4d50a3e]
url: https://github.com/intel-lab-lkp/linux/commits/Zijun-Hu/of-Fix-API-of_find_node_opts_by_path-finding-OF-device-node-failure/20241216-084408
base: 0f7ca6f69354e0c3923bbc28c92d0ecab4d50a3e
patch link: https://lore.kernel.org/r/20241216-of_core_fix-v2-6-e69b8f60da63%40quicinc.com
patch subject: [PATCH v2 6/7] of: Fix potential wrong MODALIAS uevent value
config: parisc-randconfig-002-20241216 (https://download.01.org/0day-ci/archive/20241216/202412161436.p6lF8p6C-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241216/202412161436.p6lF8p6C-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412161436.p6lF8p6C-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from include/linux/clk-provider.h:9,
from lib/vsprintf.c:23:
include/linux/of.h: In function 'of_modalias':
>> include/linux/of.h:764:16: error: returning 'int' from a function with return type 'char *' makes pointer from integer without a cast [-Wint-conversion]
764 | return -ENODEV;
| ^
lib/vsprintf.c: In function 'va_format':
lib/vsprintf.c:1683:9: warning: function 'va_format' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
1683 | buf += vsnprintf(buf, end > buf ? end - buf : 0, va_fmt->fmt, va);
| ^~~
--
In file included from lib/logic_pio.c:11:
include/linux/of.h: In function 'of_modalias':
>> include/linux/of.h:764:16: error: returning 'int' from a function with return type 'char *' makes pointer from integer without a cast [-Wint-conversion]
764 | return -ENODEV;
| ^
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for GET_FREE_REGION
Depends on [n]: SPARSEMEM [=n]
Selected by [y]:
- RESOURCE_KUNIT_TEST [=y] && RUNTIME_TESTING_MENU [=y] && KUNIT [=y]
vim +764 include/linux/of.h
bd69f73f2c81ee Grant Likely 2013-02-10 761
f1f6eae8bdfdfc Zijun Hu 2024-12-16 762 static inline char *of_modalias(const struct device_node *np, ssize_t *lenp)
bd7a7ed774afd1 Miquel Raynal 2023-04-04 763 {
bd7a7ed774afd1 Miquel Raynal 2023-04-04 @764 return -ENODEV;
bd7a7ed774afd1 Miquel Raynal 2023-04-04 765 }
bd7a7ed774afd1 Miquel Raynal 2023-04-04 766
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/7] of: unittest: Add a test case for API of_find_node_opts_by_path()
2024-12-16 0:40 ` [PATCH v2 2/7] of: unittest: Add a test case for API of_find_node_opts_by_path() Zijun Hu
@ 2024-12-16 19:23 ` Rob Herring
2024-12-16 21:29 ` Rob Herring
0 siblings, 1 reply; 13+ messages in thread
From: Rob Herring @ 2024-12-16 19:23 UTC (permalink / raw)
To: Zijun Hu
Cc: Saravana Kannan, Maxime Ripard, Robin Murphy, Grant Likely,
devicetree, linux-kernel, Zijun Hu
On Sun, Dec 15, 2024 at 6:41 PM Zijun Hu <zijun_hu@icloud.com> wrote:
>
> From: Zijun Hu <quic_zijuhu@quicinc.com>
>
> To test of_find_node_opts_by_path() take @path argument with pattern:
>
> "alias-name/node-name-1/.../node-name-N:options", for example:
> "testcase-alias/phandle-tests/consumer-a:testaliasoption"
The test passes with or without patch 1 applied.
Rob
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/7] of: unittest: Add a test case for API of_find_node_opts_by_path()
2024-12-16 19:23 ` Rob Herring
@ 2024-12-16 21:29 ` Rob Herring
0 siblings, 0 replies; 13+ messages in thread
From: Rob Herring @ 2024-12-16 21:29 UTC (permalink / raw)
To: Zijun Hu
Cc: Saravana Kannan, Maxime Ripard, Robin Murphy, Grant Likely,
devicetree, linux-kernel, Zijun Hu
On Mon, Dec 16, 2024 at 1:23 PM Rob Herring <robh@kernel.org> wrote:
>
> On Sun, Dec 15, 2024 at 6:41 PM Zijun Hu <zijun_hu@icloud.com> wrote:
> >
> > From: Zijun Hu <quic_zijuhu@quicinc.com>
> >
> > To test of_find_node_opts_by_path() take @path argument with pattern:
> >
> > "alias-name/node-name-1/.../node-name-N:options", for example:
> > "testcase-alias/phandle-tests/consumer-a:testaliasoption"
>
> The test passes with or without patch 1 applied.
Sorry, an error running the test on my part. This and patch 1 applied.
Thanks,
Rob
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2024-12-16 21:29 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-16 0:40 [PATCH v2 0/7] of: fix bugs and improve codes Zijun Hu
2024-12-16 0:40 ` [PATCH v2 1/7] of: Fix API of_find_node_opts_by_path() finding OF device node failure Zijun Hu
2024-12-16 0:40 ` [PATCH v2 2/7] of: unittest: Add a test case for API of_find_node_opts_by_path() Zijun Hu
2024-12-16 19:23 ` Rob Herring
2024-12-16 21:29 ` Rob Herring
2024-12-16 0:40 ` [PATCH v2 3/7] of: Correct child specifier used as input of the 2nd nexus node Zijun Hu
2024-12-16 0:40 ` [PATCH v2 4/7] of: Exchange implementation between of_property_present() and of_property_read_bool() Zijun Hu
2024-12-16 0:40 ` [PATCH v2 5/7] of: Fix available buffer size calculating error in API of_device_uevent_modalias() Zijun Hu
2024-12-16 0:40 ` [PATCH v2 6/7] of: Fix potential wrong MODALIAS uevent value Zijun Hu
2024-12-16 3:42 ` kernel test robot
2024-12-16 3:52 ` kernel test robot
2024-12-16 7:02 ` kernel test robot
2024-12-16 0:40 ` [PATCH v2 7/7] of: Do not expose of_alias_scan() and correct its comments Zijun Hu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox