mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-04-11 00:33:54 +00:00
net: remove ifalias on empty given alias
This patch removes the potentially allocated ifalias when the (new) given alias is empty. E.g. when setting echo "" > /sys/class/net/eth0/ifalias Signed-off-by: Oliver Hartkopp <oliver@hartkopp.net> Acked-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d87798450a
commit
96ca4a2cc1
1 changed files with 8 additions and 0 deletions
|
@ -967,6 +967,14 @@ int dev_set_alias(struct net_device *dev, const char *alias, size_t len)
|
||||||
if (len >= IFALIASZ)
|
if (len >= IFALIASZ)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (!len) {
|
||||||
|
if (dev->ifalias) {
|
||||||
|
kfree(dev->ifalias);
|
||||||
|
dev->ifalias = NULL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
dev->ifalias = krealloc(dev->ifalias, len+1, GFP_KERNEL);
|
dev->ifalias = krealloc(dev->ifalias, len+1, GFP_KERNEL);
|
||||||
if (!dev->ifalias)
|
if (!dev->ifalias)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
Loading…
Add table
Reference in a new issue