summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorOliver Hartkopp <oliver@hartkopp.net>2008-09-24 04:23:19 (GMT)
committerDavid S. Miller <davem@davemloft.net>2008-09-24 04:23:19 (GMT)
commit96ca4a2cc1454cf633a1e0796b7ef39d937b87ec (patch)
tree9031c5040ab0dadb3f2c5eb39ec9a4ffd1b53c2d /net
parentd87798450a7635ab1bcc80271a13ce4a53b016a9 (diff)
downloadlinux-96ca4a2cc1454cf633a1e0796b7ef39d937b87ec.tar.xz
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>
Diffstat (limited to 'net')
-rw-r--r--net/core/dev.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index e913905..a90737f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -967,6 +967,14 @@ int dev_set_alias(struct net_device *dev, const char *alias, size_t len)
if (len >= IFALIASZ)
return -EINVAL;
+ if (!len) {
+ if (dev->ifalias) {
+ kfree(dev->ifalias);
+ dev->ifalias = NULL;
+ }
+ return 0;
+ }
+
dev->ifalias = krealloc(dev->ifalias, len+1, GFP_KERNEL);
if (!dev->ifalias)
return -ENOMEM;