From: Oliver Hartkopp Date: Wed, 24 Sep 2008 04:23:19 +0000 (-0700) Subject: net: remove ifalias on empty given alias X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=96ca4a2cc1454cf633a1e0796b7ef39d937b87ec;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.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 e91390533999..a90737fe2472 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;