Patchwork [U-Boot] Add some missing endian conversions in fdt_support.c

login
register
mail settings
Submitter Gabe Black
Date Nov. 8, 2011, 9:05 a.m.
Message ID <1320743132-30994-1-git-send-email-gabeblack@chromium.org>
Download mbox | patch
Permalink /patch/124296/
State Accepted
Commit de16606ae3445c3822720487178ecf7fbdd0c378
Headers show

Comments

Gabe Black - Nov. 8, 2011, 9:05 a.m.
Some functions in fdt_support.c use fdt_getprop to read 32 bit values out of
the device tree, but then use them directly without doing any endian
conversion. Because they check for a value that doesn't actually appear in
practice, the functions continued to work even though they're incorrect.
This change adds the missing conversions.

Signed-off-by: Gabe Black <gabeblack@chromium.org>
---
 common/fdt_support.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Mike Frysinger - Nov. 8, 2011, 1:47 p.m.
+fdt maintainer

On Tuesday 08 November 2011 04:05:32 Gabe Black wrote:
> Some functions in fdt_support.c use fdt_getprop to read 32 bit values out
> of the device tree, but then use them directly without doing any endian
> conversion. Because they check for a value that doesn't actually appear in
> practice, the functions continued to work even though they're incorrect.
> This change adds the missing conversions.
> 
> Signed-off-by: Gabe Black <gabeblack@chromium.org>
> ---
>  common/fdt_support.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/common/fdt_support.c b/common/fdt_support.c
> index bdda64d..c501604 100644
> --- a/common/fdt_support.c
> +++ b/common/fdt_support.c
> @@ -61,7 +61,7 @@ u32 fdt_getprop_u32_default(void *fdt, const char *path,
> const char *prop,
> 
>  	val = fdt_getprop(fdt, off, prop, NULL);
>  	if (val)
> -		return *val;
> +		return fdt32_to_cpu(*val);
>  	else
>  		return dflt;
>  }
> @@ -372,7 +372,7 @@ static int get_cells_len(void *blob, char
> *nr_cells_name) const u32 *cell;
> 
>  	cell = fdt_getprop(blob, 0, nr_cells_name, NULL);
> -	if (cell && *cell == 2)
> +	if (cell && fdt32_to_cpu(*cell) == 2)
>  		return 8;
> 
>  	return 4;
Gabe Black - Nov. 13, 2011, 2:07 a.m.
Bump.

On Tue, Nov 8, 2011 at 5:47 AM, Mike Frysinger <vapier@gentoo.org> wrote:

> +fdt maintainer
>
> On Tuesday 08 November 2011 04:05:32 Gabe Black wrote:
> > Some functions in fdt_support.c use fdt_getprop to read 32 bit values out
> > of the device tree, but then use them directly without doing any endian
> > conversion. Because they check for a value that doesn't actually appear
> in
> > practice, the functions continued to work even though they're incorrect.
> > This change adds the missing conversions.
> >
> > Signed-off-by: Gabe Black <gabeblack@chromium.org>
> > ---
> >  common/fdt_support.c |    4 ++--
> >  1 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/common/fdt_support.c b/common/fdt_support.c
> > index bdda64d..c501604 100644
> > --- a/common/fdt_support.c
> > +++ b/common/fdt_support.c
> > @@ -61,7 +61,7 @@ u32 fdt_getprop_u32_default(void *fdt, const char
> *path,
> > const char *prop,
> >
> >       val = fdt_getprop(fdt, off, prop, NULL);
> >       if (val)
> > -             return *val;
> > +             return fdt32_to_cpu(*val);
> >       else
> >               return dflt;
> >  }
> > @@ -372,7 +372,7 @@ static int get_cells_len(void *blob, char
> > *nr_cells_name) const u32 *cell;
> >
> >       cell = fdt_getprop(blob, 0, nr_cells_name, NULL);
> > -     if (cell && *cell == 2)
> > +     if (cell && fdt32_to_cpu(*cell) == 2)
> >               return 8;
> >
> >       return 4;
>
Jerry Van Baren - Nov. 13, 2011, 5:04 p.m.
On 11/08/2011 04:05 AM, Gabe Black wrote:
> Some functions in fdt_support.c use fdt_getprop to read 32 bit values out of
> the device tree, but then use them directly without doing any endian
> conversion. Because they check for a value that doesn't actually appear in
> practice, the functions continued to work even though they're incorrect.
> This change adds the missing conversions.
>
> Signed-off-by: Gabe Black<gabeblack@chromium.org>
> ---
>   common/fdt_support.c |    4 ++--
>   1 files changed, 2 insertions(+), 2 deletions(-)

Applied and requested a bugfix pull.

Thanks,
gvb

Patch

diff --git a/common/fdt_support.c b/common/fdt_support.c
index bdda64d..c501604 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -61,7 +61,7 @@  u32 fdt_getprop_u32_default(void *fdt, const char *path, const char *prop,
 
 	val = fdt_getprop(fdt, off, prop, NULL);
 	if (val)
-		return *val;
+		return fdt32_to_cpu(*val);
 	else
 		return dflt;
 }
@@ -372,7 +372,7 @@  static int get_cells_len(void *blob, char *nr_cells_name)
 	const u32 *cell;
 
 	cell = fdt_getprop(blob, 0, nr_cells_name, NULL);
-	if (cell && *cell == 2)
+	if (cell && fdt32_to_cpu(*cell) == 2)
 		return 8;
 
 	return 4;