[U-Boot] [PATCH 1/2] net/eth.c: throw BUG for eth_get_dev_by_name(NULL)

Helmut Raiger helmut.raiger at hale.at
Mon Aug 22 12:17:17 CEST 2011


eth_get_dev_by_name() is not safe to use for devname being NULL
as it uses strcmp. This patch makes it fail with a BUG().

Signed-off-by: Helmut Raiger <helmut.raiger at hale.at>
---
V2: use BUG_ON() instead of gracefully returning 0

 net/eth.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/net/eth.c b/net/eth.c
index 6523834..deb41ba 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -107,6 +107,8 @@ struct eth_device *eth_get_dev_by_name(const char *devname)
 {
 	struct eth_device *dev, *target_dev;
 
+	BUG_ON(devname == NULL);
+
 	if (!eth_devices)
 		return NULL;
 
-- 
1.7.4.4



--
Scanned by MailScanner.



More information about the U-Boot mailing list