[U-Boot] [PATCH v2] disk/part.c: Fix device enumeration through API

Anatolij Gustschin agust at denx.de
Tue Mar 27 11:54:00 CEST 2012

From: Tim Kientzle <kientzle at freebsd.org>

The patch below fixes device enumeration through the U-Boot API.

Device enumeration crashes when the system in question doesn't
have any RAM mapped to address zero (I discovered this on a
BeagleBone board), since the enumeration calls get_dev with a
NULL ifname sometimes which then gets passed down to strncmp().

This fix simply ensures that get_dev returns NULL when invoked
with a NULL ifname.

Signed-off-by: Tim Kientzle <kientzle at freebsd.org>
Signed-off-by: Anatolij Gustschin <agust at denx.de>
 - resend with fixed whitespace errors and properly added
   commit log.

I've queued this patch in my staging branch. Thanks!


 disk/part.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index f07a17f..8ca5d4b 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -80,6 +80,9 @@ block_dev_desc_t *get_dev(char* ifname, int dev)
 	block_dev_desc_t* (*reloc_get_dev)(int dev);
 	char *name;
+	if (!ifname)
+		return NULL;
 	name = drvr->name;
 	name += gd->reloc_off;

More information about the U-Boot mailing list