network: check result of if_nametoindex().

When we want to get index of a ifname which does not
exist, we should return a -EINVAL in this case.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
Dongsheng Yang 2014-09-11 21:51:35 +08:00 committed by Serge Hallyn
parent 599781664b
commit 49428bf306

View File

@ -144,6 +144,8 @@ int lxc_netdev_move_by_name(const char *ifname, pid_t pid)
return -EINVAL;
index = if_nametoindex(ifname);
if (!index)
return -EINVAL;
return lxc_netdev_move_by_index(index, pid);
}