Skip to content

Commit

Permalink
net: remove ifalias on empty given alias
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Oliver Hartkopp authored and David S. Miller committed Sep 24, 2008
1 parent d877984 commit 96ca4a2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 96ca4a2

Please sign in to comment.