[PATCH] of: Fix of_get_stdoutpath() when property does not contain a colon

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



With 90f70dbe29 'buf' only gets initialized when the stdout-path
property contains a colon. It changes

	p = strchrnul(value, ':');
	buf = xstrndup(value, p - value);

to
	p = strchrnul(value, ':');
	if (*p)
		buf = xstrndup(value, p - value);

With the latter we end up calling of_find_node_by_path_or_alias() with
a NULL pointer, so no node can be found.

Fix this by restoring the original behaviour.

Fixes: 90f70dbe29 ("of: split part of of_get_stdoutpath into of_find_node_by_chosen")
Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 drivers/of/base.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 34854d9b0d..fb23594c7a 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2680,7 +2680,7 @@ struct device_node *of_find_node_by_chosen(const char *propname,
 					   const char **options)
 {
 	const char *value, *p;
-	char *buf = NULL;
+	char *buf;
 	struct device_node *dn;
 
 	value = of_get_property(of_chosen, propname, NULL);
@@ -2688,8 +2688,7 @@ struct device_node *of_find_node_by_chosen(const char *propname,
 		return NULL;
 
 	p = strchrnul(value, ':');
-	if (*p)
-		buf = xstrndup(value, p - value);
+	buf = xstrndup(value, p - value);
 
 	dn = of_find_node_by_path_or_alias(NULL, buf);
 
-- 
2.30.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux