LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] libfdt: Teach fdt_path_offset() about ':' path separator
@ 2015-03-04 16:44 Peter Hurley
2015-03-05 15:23 ` Rob Herring
0 siblings, 1 reply; 4+ messages in thread
From: Peter Hurley @ 2015-03-04 16:44 UTC (permalink / raw)
To: Grant Likely, Rob Herring
Cc: devicetree, linux-kernel, Andrew Lunn, Peter Hurley,
Leif Lindholm, stable
stdout-path defines ':' as a path separator and commit 75c28c09af99a
("of: add optional options parameter to of_find_node_by_path()") added
the necessary support to parse paths terminated with ':' path separator.
commit 7914a7c5651a5 ("of: support passing console options with
stdout-path") added options string support to the stdout-path property,
which broke earlycon.
Add the same support to fdt_path_offset() so earlycon can parse and
process stdout-path properties containing an options string.
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: <stable@vger.kernel.org> # 3.19+
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
scripts/dtc/libfdt/fdt_ro.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/scripts/dtc/libfdt/fdt_ro.c b/scripts/dtc/libfdt/fdt_ro.c
index 02b6d68..a96e452 100644
--- a/scripts/dtc/libfdt/fdt_ro.c
+++ b/scripts/dtc/libfdt/fdt_ro.c
@@ -156,7 +156,8 @@ int fdt_subnode_offset(const void *fdt, int parentoffset,
int fdt_path_offset(const void *fdt, const char *path)
{
- const char *end = path + strlen(path);
+ const char *separator = strchr(path, ':');
+ const char *end = separator ? separator : path + strlen(path);
const char *p = path;
int offset = 0;
@@ -166,7 +167,7 @@ int fdt_path_offset(const void *fdt, const char *path)
if (*path != '/') {
const char *q = strchr(path, '/');
- if (!q)
+ if (!q || q > end)
q = end;
p = fdt_get_alias_namelen(fdt, p, q - p);
@@ -177,7 +178,7 @@ int fdt_path_offset(const void *fdt, const char *path)
p = q;
}
- while (*p) {
+ while (p < end) {
const char *q;
while (*p == '/')
@@ -185,7 +186,7 @@ int fdt_path_offset(const void *fdt, const char *path)
if (! *p)
return offset;
q = strchr(p, '/');
- if (! q)
+ if (!q || q > end)
q = end;
offset = fdt_subnode_offset_namelen(fdt, offset, p, q-p);
--
2.3.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libfdt: Teach fdt_path_offset() about ':' path separator
2015-03-04 16:44 [PATCH] libfdt: Teach fdt_path_offset() about ':' path separator Peter Hurley
@ 2015-03-05 15:23 ` Rob Herring
2015-03-05 17:04 ` Peter Hurley
0 siblings, 1 reply; 4+ messages in thread
From: Rob Herring @ 2015-03-05 15:23 UTC (permalink / raw)
To: Peter Hurley
Cc: Grant Likely, Rob Herring, devicetree, linux-kernel, Andrew Lunn,
Leif Lindholm
On Wed, Mar 4, 2015 at 10:44 AM, Peter Hurley <peter@hurleysoftware.com> wrote:
> stdout-path defines ':' as a path separator and commit 75c28c09af99a
> ("of: add optional options parameter to of_find_node_by_path()") added
> the necessary support to parse paths terminated with ':' path separator.
> commit 7914a7c5651a5 ("of: support passing console options with
> stdout-path") added options string support to the stdout-path property,
> which broke earlycon.
>
> Add the same support to fdt_path_offset() so earlycon can parse and
> process stdout-path properties containing an options string.
>
> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> Cc: <stable@vger.kernel.org> # 3.19+
> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
This needs to be first applied to upstream dtc[1]. Please do a patch
against dtc and send to devicetree-compiler list.
Rob
[1] https://git.kernel.org/cgit/linux/kernel/git/jdl/dtc.git/
> ---
> scripts/dtc/libfdt/fdt_ro.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/dtc/libfdt/fdt_ro.c b/scripts/dtc/libfdt/fdt_ro.c
> index 02b6d68..a96e452 100644
> --- a/scripts/dtc/libfdt/fdt_ro.c
> +++ b/scripts/dtc/libfdt/fdt_ro.c
> @@ -156,7 +156,8 @@ int fdt_subnode_offset(const void *fdt, int parentoffset,
>
> int fdt_path_offset(const void *fdt, const char *path)
> {
> - const char *end = path + strlen(path);
> + const char *separator = strchr(path, ':');
> + const char *end = separator ? separator : path + strlen(path);
> const char *p = path;
> int offset = 0;
>
> @@ -166,7 +167,7 @@ int fdt_path_offset(const void *fdt, const char *path)
> if (*path != '/') {
> const char *q = strchr(path, '/');
>
> - if (!q)
> + if (!q || q > end)
> q = end;
>
> p = fdt_get_alias_namelen(fdt, p, q - p);
> @@ -177,7 +178,7 @@ int fdt_path_offset(const void *fdt, const char *path)
> p = q;
> }
>
> - while (*p) {
> + while (p < end) {
> const char *q;
>
> while (*p == '/')
> @@ -185,7 +186,7 @@ int fdt_path_offset(const void *fdt, const char *path)
> if (! *p)
> return offset;
> q = strchr(p, '/');
> - if (! q)
> + if (!q || q > end)
> q = end;
>
> offset = fdt_subnode_offset_namelen(fdt, offset, p, q-p);
> --
> 2.3.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libfdt: Teach fdt_path_offset() about ':' path separator
2015-03-05 15:23 ` Rob Herring
@ 2015-03-05 17:04 ` Peter Hurley
2015-03-05 20:48 ` Rob Herring
0 siblings, 1 reply; 4+ messages in thread
From: Peter Hurley @ 2015-03-05 17:04 UTC (permalink / raw)
To: Rob Herring
Cc: Grant Likely, Rob Herring, devicetree, linux-kernel, Andrew Lunn,
Leif Lindholm, Greg KH
[ +cc Greg KH ]
On 03/05/2015 10:23 AM, Rob Herring wrote:
> On Wed, Mar 4, 2015 at 10:44 AM, Peter Hurley <peter@hurleysoftware.com> wrote:
>> stdout-path defines ':' as a path separator and commit 75c28c09af99a
>> ("of: add optional options parameter to of_find_node_by_path()") added
>> the necessary support to parse paths terminated with ':' path separator.
>> commit 7914a7c5651a5 ("of: support passing console options with
>> stdout-path") added options string support to the stdout-path property,
>> which broke earlycon.
>>
>> Add the same support to fdt_path_offset() so earlycon can parse and
>> process stdout-path properties containing an options string.
>>
>> Cc: Leif Lindholm <leif.lindholm@linaro.org>
>> Cc: <stable@vger.kernel.org> # 3.19+
>> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
>
> This needs to be first applied to upstream dtc[1]. Please do a patch
> against dtc and send to devicetree-compiler list.
Sure, I can do that, but then how is this patch going to end up in
3.19-stable?
Regards,
Peter Hurley
> Rob
>
> [1] https://git.kernel.org/cgit/linux/kernel/git/jdl/dtc.git/
>
>> ---
>> scripts/dtc/libfdt/fdt_ro.c | 9 +++++----
>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/scripts/dtc/libfdt/fdt_ro.c b/scripts/dtc/libfdt/fdt_ro.c
>> index 02b6d68..a96e452 100644
>> --- a/scripts/dtc/libfdt/fdt_ro.c
>> +++ b/scripts/dtc/libfdt/fdt_ro.c
>> @@ -156,7 +156,8 @@ int fdt_subnode_offset(const void *fdt, int parentoffset,
>>
>> int fdt_path_offset(const void *fdt, const char *path)
>> {
>> - const char *end = path + strlen(path);
>> + const char *separator = strchr(path, ':');
>> + const char *end = separator ? separator : path + strlen(path);
>> const char *p = path;
>> int offset = 0;
>>
>> @@ -166,7 +167,7 @@ int fdt_path_offset(const void *fdt, const char *path)
>> if (*path != '/') {
>> const char *q = strchr(path, '/');
>>
>> - if (!q)
>> + if (!q || q > end)
>> q = end;
>>
>> p = fdt_get_alias_namelen(fdt, p, q - p);
>> @@ -177,7 +178,7 @@ int fdt_path_offset(const void *fdt, const char *path)
>> p = q;
>> }
>>
>> - while (*p) {
>> + while (p < end) {
>> const char *q;
>>
>> while (*p == '/')
>> @@ -185,7 +186,7 @@ int fdt_path_offset(const void *fdt, const char *path)
>> if (! *p)
>> return offset;
>> q = strchr(p, '/');
>> - if (! q)
>> + if (!q || q > end)
>> q = end;
>>
>> offset = fdt_subnode_offset_namelen(fdt, offset, p, q-p);
>> --
>> 2.3.1
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] libfdt: Teach fdt_path_offset() about ':' path separator
2015-03-05 17:04 ` Peter Hurley
@ 2015-03-05 20:48 ` Rob Herring
0 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2015-03-05 20:48 UTC (permalink / raw)
To: Peter Hurley
Cc: Grant Likely, Rob Herring, devicetree, linux-kernel, Andrew Lunn,
Leif Lindholm, Greg KH
On Thu, Mar 5, 2015 at 11:04 AM, Peter Hurley <peter@hurleysoftware.com> wrote:
> [ +cc Greg KH ]
>
> On 03/05/2015 10:23 AM, Rob Herring wrote:
>> On Wed, Mar 4, 2015 at 10:44 AM, Peter Hurley <peter@hurleysoftware.com> wrote:
>>> stdout-path defines ':' as a path separator and commit 75c28c09af99a
>>> ("of: add optional options parameter to of_find_node_by_path()") added
>>> the necessary support to parse paths terminated with ':' path separator.
>>> commit 7914a7c5651a5 ("of: support passing console options with
>>> stdout-path") added options string support to the stdout-path property,
>>> which broke earlycon.
>>>
>>> Add the same support to fdt_path_offset() so earlycon can parse and
>>> process stdout-path properties containing an options string.
>>>
>>> Cc: Leif Lindholm <leif.lindholm@linaro.org>
>>> Cc: <stable@vger.kernel.org> # 3.19+
>>> Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
>>
>> This needs to be first applied to upstream dtc[1]. Please do a patch
>> against dtc and send to devicetree-compiler list.
>
> Sure, I can do that, but then how is this patch going to end up in
> 3.19-stable?
I'll apply it tagged for stable once it is in dtc.
Rob
>
> Regards,
> Peter Hurley
>
>> Rob
>>
>> [1] https://git.kernel.org/cgit/linux/kernel/git/jdl/dtc.git/
>>
>>> ---
>>> scripts/dtc/libfdt/fdt_ro.c | 9 +++++----
>>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/scripts/dtc/libfdt/fdt_ro.c b/scripts/dtc/libfdt/fdt_ro.c
>>> index 02b6d68..a96e452 100644
>>> --- a/scripts/dtc/libfdt/fdt_ro.c
>>> +++ b/scripts/dtc/libfdt/fdt_ro.c
>>> @@ -156,7 +156,8 @@ int fdt_subnode_offset(const void *fdt, int parentoffset,
>>>
>>> int fdt_path_offset(const void *fdt, const char *path)
>>> {
>>> - const char *end = path + strlen(path);
>>> + const char *separator = strchr(path, ':');
>>> + const char *end = separator ? separator : path + strlen(path);
>>> const char *p = path;
>>> int offset = 0;
>>>
>>> @@ -166,7 +167,7 @@ int fdt_path_offset(const void *fdt, const char *path)
>>> if (*path != '/') {
>>> const char *q = strchr(path, '/');
>>>
>>> - if (!q)
>>> + if (!q || q > end)
>>> q = end;
>>>
>>> p = fdt_get_alias_namelen(fdt, p, q - p);
>>> @@ -177,7 +178,7 @@ int fdt_path_offset(const void *fdt, const char *path)
>>> p = q;
>>> }
>>>
>>> - while (*p) {
>>> + while (p < end) {
>>> const char *q;
>>>
>>> while (*p == '/')
>>> @@ -185,7 +186,7 @@ int fdt_path_offset(const void *fdt, const char *path)
>>> if (! *p)
>>> return offset;
>>> q = strchr(p, '/');
>>> - if (! q)
>>> + if (!q || q > end)
>>> q = end;
>>>
>>> offset = fdt_subnode_offset_namelen(fdt, offset, p, q-p);
>>> --
>>> 2.3.1
>>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-03-05 20:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-04 16:44 [PATCH] libfdt: Teach fdt_path_offset() about ':' path separator Peter Hurley
2015-03-05 15:23 ` Rob Herring
2015-03-05 17:04 ` Peter Hurley
2015-03-05 20:48 ` Rob Herring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).