mirror of https://gitee.com/openkylin/linux.git
driver: tun: Move tun check into the block of TUNSETIFF condition check
When cmd is TUNSETIFF and tun is not null, the original codes go ahead, then reach the default case of switch(cmd) and set the ret is -EINVAL. It is not clear for readers. Now move the tun check into the block of TUNSETIFF condition check, and return -EEXIST instead of -EINVAL when the tfile already owns one tun. Signed-off-by: Gao Feng <fgao@ikuai8.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
93a205ee98
commit
0f16bc1355
|
@ -2005,7 +2005,11 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
|
|||
rtnl_lock();
|
||||
|
||||
tun = __tun_get(tfile);
|
||||
if (cmd == TUNSETIFF && !tun) {
|
||||
if (cmd == TUNSETIFF) {
|
||||
ret = -EEXIST;
|
||||
if (tun)
|
||||
goto unlock;
|
||||
|
||||
ifr.ifr_name[IFNAMSIZ-1] = '\0';
|
||||
|
||||
ret = tun_set_iff(sock_net(&tfile->sk), file, &ifr);
|
||||
|
|
Loading…
Reference in New Issue