diff options
| -rw-r--r-- | drivers/of/base.c | 11 | ||||
| -rw-r--r-- | drivers/of/irq.c | 10 | ||||
| -rw-r--r-- | drivers/of/unittest.c | 5 |
3 files changed, 14 insertions, 12 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index adb8764861c0..8f165b112e03 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
| @@ -715,13 +715,8 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent, | |||
| 715 | { | 715 | { |
| 716 | struct device_node *child; | 716 | struct device_node *child; |
| 717 | int len; | 717 | int len; |
| 718 | const char *end; | ||
| 719 | 718 | ||
| 720 | end = strchr(path, ':'); | 719 | len = strcspn(path, "/:"); |
| 721 | if (!end) | ||
| 722 | end = strchrnul(path, '/'); | ||
| 723 | |||
| 724 | len = end - path; | ||
| 725 | if (!len) | 720 | if (!len) |
| 726 | return NULL; | 721 | return NULL; |
| 727 | 722 | ||
| @@ -1893,10 +1888,8 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align)) | |||
| 1893 | name = of_get_property(of_chosen, "linux,stdout-path", NULL); | 1888 | name = of_get_property(of_chosen, "linux,stdout-path", NULL); |
| 1894 | if (IS_ENABLED(CONFIG_PPC) && !name) | 1889 | if (IS_ENABLED(CONFIG_PPC) && !name) |
| 1895 | name = of_get_property(of_aliases, "stdout", NULL); | 1890 | name = of_get_property(of_aliases, "stdout", NULL); |
| 1896 | if (name) { | 1891 | if (name) |
| 1897 | of_stdout = of_find_node_opts_by_path(name, &of_stdout_options); | 1892 | of_stdout = of_find_node_opts_by_path(name, &of_stdout_options); |
| 1898 | add_preferred_console("stdout-path", 0, NULL); | ||
| 1899 | } | ||
| 1900 | } | 1893 | } |
| 1901 | 1894 | ||
| 1902 | if (!of_aliases) | 1895 | if (!of_aliases) |
diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 0d7765807f49..1a7980692f25 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c | |||
| @@ -290,7 +290,7 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar | |||
| 290 | struct device_node *p; | 290 | struct device_node *p; |
| 291 | const __be32 *intspec, *tmp, *addr; | 291 | const __be32 *intspec, *tmp, *addr; |
| 292 | u32 intsize, intlen; | 292 | u32 intsize, intlen; |
| 293 | int i, res = -EINVAL; | 293 | int i, res; |
| 294 | 294 | ||
| 295 | pr_debug("of_irq_parse_one: dev=%s, index=%d\n", of_node_full_name(device), index); | 295 | pr_debug("of_irq_parse_one: dev=%s, index=%d\n", of_node_full_name(device), index); |
| 296 | 296 | ||
| @@ -323,15 +323,19 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar | |||
| 323 | 323 | ||
| 324 | /* Get size of interrupt specifier */ | 324 | /* Get size of interrupt specifier */ |
| 325 | tmp = of_get_property(p, "#interrupt-cells", NULL); | 325 | tmp = of_get_property(p, "#interrupt-cells", NULL); |
| 326 | if (tmp == NULL) | 326 | if (tmp == NULL) { |
| 327 | res = -EINVAL; | ||
| 327 | goto out; | 328 | goto out; |
| 329 | } | ||
| 328 | intsize = be32_to_cpu(*tmp); | 330 | intsize = be32_to_cpu(*tmp); |
| 329 | 331 | ||
| 330 | pr_debug(" intsize=%d intlen=%d\n", intsize, intlen); | 332 | pr_debug(" intsize=%d intlen=%d\n", intsize, intlen); |
| 331 | 333 | ||
| 332 | /* Check index */ | 334 | /* Check index */ |
| 333 | if ((index + 1) * intsize > intlen) | 335 | if ((index + 1) * intsize > intlen) { |
| 336 | res = -EINVAL; | ||
| 334 | goto out; | 337 | goto out; |
| 338 | } | ||
| 335 | 339 | ||
| 336 | /* Copy intspec into irq structure */ | 340 | /* Copy intspec into irq structure */ |
| 337 | intspec += index * intsize; | 341 | intspec += index * intsize; |
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index aba8946cac46..52c45c7df07f 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c | |||
| @@ -97,6 +97,11 @@ static void __init of_selftest_find_node_by_name(void) | |||
| 97 | "option path test, subcase #1 failed\n"); | 97 | "option path test, subcase #1 failed\n"); |
| 98 | of_node_put(np); | 98 | of_node_put(np); |
| 99 | 99 | ||
| 100 | np = of_find_node_opts_by_path("/testcase-data/testcase-device1:test/option", &options); | ||
| 101 | selftest(np && !strcmp("test/option", options), | ||
| 102 | "option path test, subcase #2 failed\n"); | ||
| 103 | of_node_put(np); | ||
| 104 | |||
| 100 | np = of_find_node_opts_by_path("/testcase-data:testoption", NULL); | 105 | np = of_find_node_opts_by_path("/testcase-data:testoption", NULL); |
| 101 | selftest(np, "NULL option path test failed\n"); | 106 | selftest(np, "NULL option path test failed\n"); |
| 102 | of_node_put(np); | 107 | of_node_put(np); |
