Commit 98749b71 authored by Wang Hai's avatar Wang Hai Committed by David S. Miller

yam: fix possible memory leak in yam_init_driver

If register_netdev(dev) fails, free_netdev(dev) needs
to be called, otherwise a memory leak will occur.

Fixes: 1da177e4 ("Linux-2.6.12-rc2")
Reported-by: default avatarHulk Robot <hulkci@huawei.com>
Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7cdee28c
...@@ -1133,6 +1133,7 @@ static int __init yam_init_driver(void) ...@@ -1133,6 +1133,7 @@ static int __init yam_init_driver(void)
err = register_netdev(dev); err = register_netdev(dev);
if (err) { if (err) {
printk(KERN_WARNING "yam: cannot register net device %s\n", dev->name); printk(KERN_WARNING "yam: cannot register net device %s\n", dev->name);
free_netdev(dev);
goto error; goto error;
} }
yam_devs[i] = dev; yam_devs[i] = dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment