diff mbox

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

Message ID 1314002733-17408-1-git-send-email-helmut.raiger@hale.at
State Superseded
Headers show

Commit Message

Helmut Raiger Aug. 22, 2011, 8:45 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

Sergei Shtylyov Aug. 22, 2011, 10:05 a.m. UTC | #1
Hello.

On 22-08-2011 12:45, 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().

> 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(-)

> diff --git a/net/eth.c b/net/eth.c
> index 6523834..25c147c 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 == 0);

    Do not use 0 instead of NULL.

WBR, Sergei
diff mbox

Patch

diff --git a/net/eth.c b/net/eth.c
index 6523834..25c147c 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 == 0);
+
 	if (!eth_devices)
 		return NULL;