From mboxrd@z Thu Jan 1 00:00:00 1970 From: Helmut Raiger Date: Wed, 06 Jul 2011 09:15:08 +0200 Subject: [U-Boot] [PATCH 1/2] net/eth.c: make eth_get_dev_by_name(NULL) safe In-Reply-To: <201107042344.55693.vapier@gentoo.org> References: <4E118AD9.9000200@hale.at> <1309775392-8282-1-git-send-email-helmut.raiger@hale.at> <201107042344.55693.vapier@gentoo.org> Message-ID: <4E140B7C.7090802@hale.at> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 07/05/2011 05:44 AM, Mike Frysinger wrote: > On Monday, July 04, 2011 06:29:51 helmut.raiger at hale.at wrote: >> eth_get_dev_by_name() is not safe to use for devname being NULL >> as it uses strcmp. This patch makes it return NULL if devname NULL >> is passed. > i'm not sure about this. passing NULL is wrong, and the caller should catch > that shouldnt it ? > -mike So what is your suggestion how to deal with it? It returns: "There is no ethernet device with name NULL" This is pretty much the only thing it can return. The user of the function may handle this situation individually like: printf("ethernet device '%s' not found\n, devname); --> "ethernet device '(NULL)' not found". A panic on a NULL pointer de-reference is probably not helpful either. Helmut -- Scanned by MailScanner.