From patchwork Wed Feb 22 06:34:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Kientzle X-Patchwork-Id: 142426 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 51890B6FA2 for ; Wed, 22 Feb 2012 20:53:25 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 342DD2808A; Wed, 22 Feb 2012 10:53:15 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NWw8Ff2ThTn8; Wed, 22 Feb 2012 10:53:15 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4D28F28098; Wed, 22 Feb 2012 10:53:03 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9A0B428083 for ; Wed, 22 Feb 2012 07:54:39 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b11ZyaeOCyxT for ; Wed, 22 Feb 2012 07:54:38 +0100 (CET) X-Greylist: delayed 1195 seconds by postgrey-1.27 at theia; Wed, 22 Feb 2012 07:54:36 CET X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from monday.kientzle.com (99-115-135-74.uvs.sntcca.sbcglobal.net [99.115.135.74]) by theia.denx.de (Postfix) with ESMTPS id 1FE4228081 for ; Wed, 22 Feb 2012 07:54:36 +0100 (CET) Received: (from root@localhost) by monday.kientzle.com (8.14.4/8.14.4) id q1M6Yatl095777 for u-boot@lists.denx.de; Wed, 22 Feb 2012 06:34:36 GMT (envelope-from kientzle@freebsd.org) Received: from [192.168.2.119] (CiscoE3000 [192.168.1.65]) by kientzle.com with SMTP id aktcejhdyjj8bh6tujtcgz23uw; for u-boot@lists.denx.de; Wed, 22 Feb 2012 06:34:36 +0000 (UTC) (envelope-from kientzle@freebsd.org) From: Tim Kientzle Date: Tue, 21 Feb 2012 22:34:35 -0800 Message-Id: <318C7EDF-BBD2-4C66-ACE7-7171BA76B34B@freebsd.org> To: u-boot@lists.denx.de Mime-Version: 1.0 (Apple Message framework v1257) X-Mailer: Apple Mail (2.1257) X-Mailman-Approved-At: Wed, 22 Feb 2012 10:53:01 +0100 Subject: [U-Boot] Patch: Fix device enumeration through API. X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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; #ifdef CONFIG_NEEDS_MANUAL_RELOC