mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ARM: rpi: avoid NULL dereference on unknown rev.
@ 2019-02-12 14:51 Tomaz Solc
  2019-02-12 20:15 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Tomaz Solc @ 2019-02-12 14:51 UTC (permalink / raw)
  To: barebox; +Cc: Tomaz Solc

"model" pointer is NULL if current board revision isn't in the list of known
boards.
---
 arch/arm/boards/raspberry-pi/rpi-common.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
index 650b26ce7..b2febec99 100644
--- a/arch/arm/boards/raspberry-pi/rpi-common.c
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -180,7 +180,7 @@ const struct rpi_model rpi_models_new_scheme[] = {
 };
 
 static int rpi_board_rev = 0;
-const struct rpi_model *model;
+const struct rpi_model *model = NULL;
 
 static void rpi_get_board_rev(void)
 {
@@ -251,6 +251,9 @@ unknown_rev:
 
 static void rpi_model_init(void)
 {
+	if (!model)
+		return;
+
 	if (!model->init)
 		return;
 
-- 
2.11.0


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

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

* Re: [PATCH] ARM: rpi: avoid NULL dereference on unknown rev.
  2019-02-12 14:51 [PATCH] ARM: rpi: avoid NULL dereference on unknown rev Tomaz Solc
@ 2019-02-12 20:15 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2019-02-12 20:15 UTC (permalink / raw)
  To: Tomaz Solc; +Cc: barebox

On Tue, Feb 12, 2019 at 03:51:10PM +0100, Tomaz Solc wrote:
> "model" pointer is NULL if current board revision isn't in the list of known
> boards.
> ---
>  arch/arm/boards/raspberry-pi/rpi-common.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
> index 650b26ce7..b2febec99 100644
> --- a/arch/arm/boards/raspberry-pi/rpi-common.c
> +++ b/arch/arm/boards/raspberry-pi/rpi-common.c
> @@ -180,7 +180,7 @@ const struct rpi_model rpi_models_new_scheme[] = {
>  };
>  
>  static int rpi_board_rev = 0;
> -const struct rpi_model *model;
> +const struct rpi_model *model = NULL;
>  
>  static void rpi_get_board_rev(void)
>  {
> @@ -251,6 +251,9 @@ unknown_rev:
>  
>  static void rpi_model_init(void)
>  {
> +	if (!model)
> +		return;
> +
>  	if (!model->init)
>  		return;
>  
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 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] 2+ messages in thread

end of thread, other threads:[~2019-02-12 20:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-12 14:51 [PATCH] ARM: rpi: avoid NULL dereference on unknown rev Tomaz Solc
2019-02-12 20:15 ` Sascha Hauer

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