diff mbox

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

Message ID 1314008237-24180-1-git-send-email-helmut.raiger@hale.at
State Accepted
Commit 7e7f903fcd7883d3646223e3cb30b50a7dfe6248
Headers show

Commit Message

Helmut Raiger Aug. 22, 2011, 10:17 a.m. UTC
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@hale.at>
---
V2: use BUG_ON() instead of gracefully returning 0

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

Comments

Mike Frysinger Aug. 22, 2011, 4:05 p.m. UTC | #1
On Monday, August 22, 2011 06:17:17 Helmut Raiger wrote:
> 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().

Acked-by: Mike Frysinger <vapier@gentoo.org>
-mike
Wolfgang Denk Sept. 8, 2011, 11:08 a.m. UTC | #2
Dear Helmut Raiger,

In message <1314008237-24180-1-git-send-email-helmut.raiger@hale.at> you wrote:
> 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@hale.at>
> ---
> V2: use BUG_ON() instead of gracefully returning 0
> 
>  net/eth.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk
diff mbox

Patch

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;