mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ARM: i.MX7/8M: Make sure the output parameter is always assigned
@ 2022-06-10  7:05 Uwe Kleine-König
  2022-06-10  7:28 ` Jürgen Borleis
  2022-06-10  7:51 ` Sascha Hauer
  0 siblings, 2 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2022-06-10  7:05 UTC (permalink / raw)
  To: barebox; +Cc: Jürgen Borleis

Callers of *_get_boot_source (e.g. start_atf() of
nxp-imx8mm-evk or protonic-imx8m) expect src to hold the bootsource
after return. So assign a value reliably.

Fixes: ea55770308c0 ("ARM: i.MX: Add i.MX7 base architecture support")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 arch/arm/mach-imx/boot.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index 63afdf1ef4ed..652e2869f2d7 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -526,6 +526,7 @@ static void __imx7_get_boot_source(enum bootsource *src, int *instance,
 		*src = BOOTSOURCE_SERIAL;
 		break;
 	default:
+		*src = BOOTSOURCE_UNKNOWN;
 		break;
 	}
 }

base-commit: 6a3f9ed1f5c55957b2ed4f460955281539e8e785
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ARM: i.MX7/8M: Make sure the output parameter is always assigned
  2022-06-10  7:05 [PATCH] ARM: i.MX7/8M: Make sure the output parameter is always assigned Uwe Kleine-König
@ 2022-06-10  7:28 ` Jürgen Borleis
  2022-06-10  7:44   ` Sascha Hauer
  2022-06-10  8:42   ` Uwe Kleine-König
  2022-06-10  7:51 ` Sascha Hauer
  1 sibling, 2 replies; 6+ messages in thread
From: Jürgen Borleis @ 2022-06-10  7:28 UTC (permalink / raw)
  To: barebox; +Cc: Uwe Kleine-König

Am Freitag, 10. Juni 2022, 09:05:57 CEST schrieb Uwe Kleine-König:
> Callers of *_get_boot_source (e.g. start_atf() of
> nxp-imx8mm-evk or protonic-imx8m) expect src to hold the bootsource
> after return. So assign a value reliably.
> 
> Fixes: ea55770308c0 ("ARM: i.MX: Add i.MX7 base architecture support")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  arch/arm/mach-imx/boot.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
> index 63afdf1ef4ed..652e2869f2d7 100644
> --- a/arch/arm/mach-imx/boot.c
> +++ b/arch/arm/mach-imx/boot.c
> @@ -526,6 +526,7 @@ static void __imx7_get_boot_source(enum bootsource *src,
> int *instance, *src = BOOTSOURCE_SERIAL;
>  		break;
>  	default:
> +		*src = BOOTSOURCE_UNKNOWN;
>  		break;
>  	}
>  }

This changes the API and - if really required - should be done for all SoC 
specific *_get_boot_sources and not for the imx7 only (IMHO).

jb

-- 
Pengutronix e.K.                       | Juergen Borleis             |
Steuerwalder Str. 21                   | https://www.pengutronix.de/ |
31137 Hildesheim, Germany              | Phone: +49-5121-206917-128  |
Amtsgericht Hildesheim, HRA 2686       | Fax:   +49-5121-206917-9    |



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ARM: i.MX7/8M: Make sure the output parameter is always assigned
  2022-06-10  7:28 ` Jürgen Borleis
@ 2022-06-10  7:44   ` Sascha Hauer
  2022-06-10  8:42   ` Uwe Kleine-König
  1 sibling, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2022-06-10  7:44 UTC (permalink / raw)
  To: Jürgen Borleis; +Cc: barebox, Uwe Kleine-König

On Fri, Jun 10, 2022 at 09:28:54AM +0200, Jürgen Borleis wrote:
> Am Freitag, 10. Juni 2022, 09:05:57 CEST schrieb Uwe Kleine-König:
> > Callers of *_get_boot_source (e.g. start_atf() of
> > nxp-imx8mm-evk or protonic-imx8m) expect src to hold the bootsource
> > after return. So assign a value reliably.
> > 
> > Fixes: ea55770308c0 ("ARM: i.MX: Add i.MX7 base architecture support")
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > ---
> >  arch/arm/mach-imx/boot.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
> > index 63afdf1ef4ed..652e2869f2d7 100644
> > --- a/arch/arm/mach-imx/boot.c
> > +++ b/arch/arm/mach-imx/boot.c
> > @@ -526,6 +526,7 @@ static void __imx7_get_boot_source(enum bootsource *src,
> > int *instance, *src = BOOTSOURCE_SERIAL;
> >  		break;
> >  	default:
> > +		*src = BOOTSOURCE_UNKNOWN;
> >  		break;
> >  	}
> >  }
> 
> This changes the API and - if really required - should be done for all SoC 
> specific *_get_boot_sources and not for the imx7 only (IMHO).

How does that change the API? It just makes sure that *src is
initialized in all cases. I found at least one case where a caller
continues with a potentially uninitialzed value.

This happens only when __imx7_get_boot_source() is called from board
code. Normally it's called via imx_boot_save_loc() which initializes
*src to BOOTSOURCE_UNKNOWN before calling into __imx7_get_boot_source().

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ARM: i.MX7/8M: Make sure the output parameter is always assigned
  2022-06-10  7:05 [PATCH] ARM: i.MX7/8M: Make sure the output parameter is always assigned Uwe Kleine-König
  2022-06-10  7:28 ` Jürgen Borleis
@ 2022-06-10  7:51 ` Sascha Hauer
  1 sibling, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2022-06-10  7:51 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: barebox, Jürgen Borleis

On Fri, Jun 10, 2022 at 09:05:57AM +0200, Uwe Kleine-König wrote:
> Callers of *_get_boot_source (e.g. start_atf() of
> nxp-imx8mm-evk or protonic-imx8m) expect src to hold the bootsource
> after return. So assign a value reliably.
> 
> Fixes: ea55770308c0 ("ARM: i.MX: Add i.MX7 base architecture support")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  arch/arm/mach-imx/boot.c | 1 +
>  1 file changed, 1 insertion(+)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
> index 63afdf1ef4ed..652e2869f2d7 100644
> --- a/arch/arm/mach-imx/boot.c
> +++ b/arch/arm/mach-imx/boot.c
> @@ -526,6 +526,7 @@ static void __imx7_get_boot_source(enum bootsource *src, int *instance,
>  		*src = BOOTSOURCE_SERIAL;
>  		break;
>  	default:
> +		*src = BOOTSOURCE_UNKNOWN;
>  		break;
>  	}
>  }
> 
> base-commit: 6a3f9ed1f5c55957b2ed4f460955281539e8e785
> -- 
> 2.30.2
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ARM: i.MX7/8M: Make sure the output parameter is always assigned
  2022-06-10  7:28 ` Jürgen Borleis
  2022-06-10  7:44   ` Sascha Hauer
@ 2022-06-10  8:42   ` Uwe Kleine-König
  2022-06-10  8:49     ` Sascha Hauer
  1 sibling, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2022-06-10  8:42 UTC (permalink / raw)
  To: Jürgen Borleis; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 2365 bytes --]

Hello,

On Fri, Jun 10, 2022 at 09:28:54AM +0200, Jürgen Borleis wrote:
> Am Freitag, 10. Juni 2022, 09:05:57 CEST schrieb Uwe Kleine-König:
> > Callers of *_get_boot_source (e.g. start_atf() of
> > nxp-imx8mm-evk or protonic-imx8m) expect src to hold the bootsource
> > after return. So assign a value reliably.
> > 
> > Fixes: ea55770308c0 ("ARM: i.MX: Add i.MX7 base architecture support")
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > ---
> >  arch/arm/mach-imx/boot.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
> > index 63afdf1ef4ed..652e2869f2d7 100644
> > --- a/arch/arm/mach-imx/boot.c
> > +++ b/arch/arm/mach-imx/boot.c
> > @@ -526,6 +526,7 @@ static void __imx7_get_boot_source(enum bootsource *src,
> > int *instance, *src = BOOTSOURCE_SERIAL;
> >  		break;
> >  	default:
> > +		*src = BOOTSOURCE_UNKNOWN;
> >  		break;
> >  	}
> >  }
> 
> This changes the API

I agree to sha here. Callers seem to expect *src to be initialised
always.

> and - if really required - should be done for all SoC 
> specific *_get_boot_sources and not for the imx7 only (IMHO).

Agreed, that would be

diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index 63afdf1ef4ed..c0608c6a8e1b 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -285,6 +285,8 @@ void imx53_get_boot_source(enum bootsource *src, int *instance)
 	default:
 		if (imx53_bootsource_nand(cfg1))
 			*src = BOOTSOURCE_NAND;
+		else
+			*src = BOOTSOURCE_UNKNOWN;
 		break;
 	}
 
@@ -464,6 +466,8 @@ void imx6_get_boot_source(enum bootsource *src, int *instance)
 	default:
 		if (imx53_bootsource_nand(bootmode))
 			*src = BOOTSOURCE_NAND;
+		else
+			*src = BOOTSOURCE_UNKNOWN;
 		break;
 	}
 }
@@ -526,6 +530,7 @@ static void __imx7_get_boot_source(enum bootsource *src, int *instance,
 		*src = BOOTSOURCE_SERIAL;
 		break;
 	default:
+		*src = BOOTSOURCE_UNKNOWN;
 		break;
 	}
 }

then.

@sha: If wrote to have already applied my patch. If you drop it, I
resend with the above diff and an adapted commit log.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ARM: i.MX7/8M: Make sure the output parameter is always assigned
  2022-06-10  8:42   ` Uwe Kleine-König
@ 2022-06-10  8:49     ` Sascha Hauer
  0 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2022-06-10  8:49 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Jürgen Borleis, barebox

On Fri, Jun 10, 2022 at 10:42:09AM +0200, Uwe Kleine-König wrote:
> Hello,
> 
> On Fri, Jun 10, 2022 at 09:28:54AM +0200, Jürgen Borleis wrote:
> > Am Freitag, 10. Juni 2022, 09:05:57 CEST schrieb Uwe Kleine-König:
> > > Callers of *_get_boot_source (e.g. start_atf() of
> > > nxp-imx8mm-evk or protonic-imx8m) expect src to hold the bootsource
> > > after return. So assign a value reliably.
> > > 
> > > Fixes: ea55770308c0 ("ARM: i.MX: Add i.MX7 base architecture support")
> > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > > ---
> > >  arch/arm/mach-imx/boot.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > > 
> > > diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
> > > index 63afdf1ef4ed..652e2869f2d7 100644
> > > --- a/arch/arm/mach-imx/boot.c
> > > +++ b/arch/arm/mach-imx/boot.c
> > > @@ -526,6 +526,7 @@ static void __imx7_get_boot_source(enum bootsource *src,
> > > int *instance, *src = BOOTSOURCE_SERIAL;
> > >  		break;
> > >  	default:
> > > +		*src = BOOTSOURCE_UNKNOWN;
> > >  		break;
> > >  	}
> > >  }
> > 
> > This changes the API
> 
> I agree to sha here. Callers seem to expect *src to be initialised
> always.
> 
> > and - if really required - should be done for all SoC 
> > specific *_get_boot_sources and not for the imx7 only (IMHO).
> 
> Agreed, that would be
> 
> diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
> index 63afdf1ef4ed..c0608c6a8e1b 100644
> --- a/arch/arm/mach-imx/boot.c
> +++ b/arch/arm/mach-imx/boot.c
> @@ -285,6 +285,8 @@ void imx53_get_boot_source(enum bootsource *src, int *instance)
>  	default:
>  		if (imx53_bootsource_nand(cfg1))
>  			*src = BOOTSOURCE_NAND;
> +		else
> +			*src = BOOTSOURCE_UNKNOWN;
>  		break;
>  	}
>  
> @@ -464,6 +466,8 @@ void imx6_get_boot_source(enum bootsource *src, int *instance)
>  	default:
>  		if (imx53_bootsource_nand(bootmode))
>  			*src = BOOTSOURCE_NAND;
> +		else
> +			*src = BOOTSOURCE_UNKNOWN;
>  		break;
>  	}
>  }
> @@ -526,6 +530,7 @@ static void __imx7_get_boot_source(enum bootsource *src, int *instance,
>  		*src = BOOTSOURCE_SERIAL;
>  		break;
>  	default:
> +		*src = BOOTSOURCE_UNKNOWN;
>  		break;
>  	}
>  }
> 
> then.
> 
> @sha: If wrote to have already applied my patch. If you drop it, I
> resend with the above diff and an adapted commit log.

Go ahead

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-10  8:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-10  7:05 [PATCH] ARM: i.MX7/8M: Make sure the output parameter is always assigned Uwe Kleine-König
2022-06-10  7:28 ` Jürgen Borleis
2022-06-10  7:44   ` Sascha Hauer
2022-06-10  8:42   ` Uwe Kleine-König
2022-06-10  8:49     ` Sascha Hauer
2022-06-10  7:51 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox