From: Oliver Hartkopp Date: Wed, 24 Sep 2008 04:23:19 +0000 (-0700) Subject: net: remove ifalias on empty given alias X-Git-Tag: v2.6.28-rc1~717^2~196 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=96ca4a2cc1454cf633a1e0796b7ef39d937b87ec;p=linux-2.6-omap-h63xx.git 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 Acked-by: Stephen Hemminger Signed-off-by: David S. Miller --- diff --git a/net/core/dev.c b/net/core/dev.c index e9139053399..a90737fe247 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;