public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Anatolij Gustschin <agust@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] Patch:  Fix device enumeration through API.
Date: Mon, 26 Mar 2012 13:06:40 +0200	[thread overview]
Message-ID: <20120326130640.4a6e91be@wker> (raw)
In-Reply-To: <318C7EDF-BBD2-4C66-ACE7-7171BA76B34B@freebsd.org>

Hi Tim,

Thanks for the patch. Please see some comments below.

On Tue, 21 Feb 2012 22:34:35 -0800
Tim Kientzle <kientzle@freebsd.org> wrote:

> The one-line 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.
> 
> This could also be fixed by reworking the device enumeration to
> never call get_dev with a NULL argument, but that's a much more
> extensive change.  (get_dev is called from several places and the
> code is driven by a list that's constructed in a way that naturally
> leaves lots of NULLs.)
> 
> Cheers,
> 
> Tim Kientzle
> 
> diff --git a/disk/part.c b/disk/part.c
> index f07a17f..1a82539 100644
> --- a/disk/part.c
> +++ b/disk/part.c
> @@ -84,7 +84,7 @@ block_dev_desc_t *get_dev(char* ifname, int dev)
>  #ifdef CONFIG_NEEDS_MANUAL_RELOC
>  	name += gd->reloc_off;
>  #endif
> -	while (drvr->name) {
> +	while (ifname && drvr->name) {
>  		name = drvr->name;
>  		reloc_get_dev = drvr->get_dev;

I would prefer just checking for ifname == NULL at the top
of the function and not on each loop iteration. Also please
add your Signed-off-by when submitting patches.

Thanks,
Anatolij

  reply	other threads:[~2012-03-26 11:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-22  6:34 [U-Boot] Patch: Fix device enumeration through API Tim Kientzle
2012-03-26 11:06 ` Anatolij Gustschin [this message]
2012-03-27  2:46   ` Tim Kientzle
2012-03-27  4:31     ` Wolfgang Denk
2012-03-27  9:54     ` [U-Boot] [PATCH v2] disk/part.c: " Anatolij Gustschin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120326130640.4a6e91be@wker \
    --to=agust@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox