Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 96ca4a2c authored by Oliver Hartkopp's avatar Oliver Hartkopp Committed by David S. Miller
Browse files

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: default avatarOliver Hartkopp <oliver@hartkopp.net>
Acked-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d8779845
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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;