of: fix bugs and improve codes
Subsystems (2)
v2 cover of: fix bugs and improve codes
This patch series is to fix bugs and improve codes for drivers/of/*.
---
Changes in v2:
- Drop applied/conflict/TBD patches.
- Correct based on Rob's comments.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
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,
Signature · 1 line
Zijun Hu <[email protected]>
PATCH v2 1/7 of: Fix API of_find_node_opts_by_path() finding OF device node failure
From: Zijun Hu <[email protected]>
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.
--- drivers/of/base.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/of/base.c +3 -3
@@ -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 */
Signature · 1 line
2.34.1
PATCH v2 2/7 of: unittest: Add a test case for API of_find_node_opts_by_path()
In reply to Zijun HuFrom: Zijun Hu <[email protected]>
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"
--- drivers/of/unittest.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/of/unittest.c +9 -0
@@ -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);
Signature · 1 line
2.34.1
Rob Herring
maintainerRe: [PATCH v2 2/7] of: unittest: Add a test case for API of_find_node_opts_by_path()
Quoted 7 lines · Zijun Hu
From: Zijun Hu <[email protected]>
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
Rob Herring
maintainerRe: [PATCH v2 2/7] of: unittest: Add a test case for API of_find_node_opts_by_path()
Quoted 11 lines · Rob Herring
Quoted 7 lines · Zijun Hu
From: Zijun Hu <[email protected]>
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
PATCH v2 3/7 of: Correct child specifier used as input of the 2nd nexus node
In reply to Zijun HuFrom: Zijun Hu <[email protected]>
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.
--- drivers/of/base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/of/base.c +1 -1
@@ -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;
Signature · 1 line
2.34.1
PATCH v2 4/7 of: Exchange implementation between of_property_present() and of_property_read_bool()
In reply to Zijun HuFrom: Zijun Hu <[email protected]>
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.
--- include/linux/of.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
include/linux/of.h +12 -11
@@ -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); }/**
Signature · 1 line
2.34.1
PATCH v2 5/7 of: Fix available buffer size calculating error in API of_device_uevent_modalias()
In reply to Zijun HuFrom: Zijun Hu <[email protected]>
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=".
--- drivers/of/device.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/of/device.c +10 -4
@@ -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 ; }
Signature · 1 line
2.34.1
PATCH v2 6/7 of: Fix potential wrong MODALIAS uevent value
In reply to Zijun HuFrom: Zijun Hu <[email protected]>
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.
--- drivers/of/device.c | 39 +++++++------------- drivers/of/module.c | 103 +++++++++++++++++++++++++++++++--------------------- include/linux/of.h | 5 +-- 3 files changed, 78 insertions(+), 69 deletions(-)
drivers/of/device.c +14 -25
@@ -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);
drivers/of/module.c +62 -41
133 lines not on this page · raw message
include/linux/of.h +2 -3
@@ -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 ; }
Signature · 1 line
2.34.1
kernel test robot
build botRe: [PATCH v2 6/7] of: Fix potential wrong MODALIAS uevent value
kernel test robot noticed the following build warnings:
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/[email protected]/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/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
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
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v2 6/7] of: Fix potential wrong MODALIAS uevent value
In reply to Zijun Hukernel test robot noticed the following build errors:
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/[email protected]/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/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
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
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v2 6/7] of: Fix potential wrong MODALIAS uevent value
In reply to Zijun Hukernel test robot noticed the following build errors:
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/[email protected]/config) compiler: hppa-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241216/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
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
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v2 7/7 of: Do not expose of_alias_scan() and correct its comments
In reply to Zijun HuFrom: Zijun Hu <[email protected]>
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.
--- 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(-)
drivers/of/base.c +2 -3
@@ -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)) {
drivers/of/of_private.h +2 -0
@@ -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. *
drivers/of/pdt.c +2 -0
@@ -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 ;
include/linux/of.h +0 -1
@@ -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);
Signature · 1 line
2.34.1