tuntap: forbid calling TUNSETIFF when detached
commit7c0c3b1a8a175437991ccc898ed66ec5e4a96208
authorJason Wang <jasowang@redhat.com>
Fri, 11 Jan 2013 16:59:33 +0000 (11 16:59 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 12 Jan 2013 03:42:02 +0000 (11 19:42 -0800)
tree504dde46c8ea52d750ebd5e9e55e8c432beb83db
parentb8deabd3eebaa96cf8d6e290d67b03f36c7f7a41
tuntap: forbid calling TUNSETIFF when detached

Michael points out that even after Stefan's fix the TUNSETIFF is still allowed
to create a new tap device. This because we only check tfile->tun but the
tfile->detached were introduced. Fix this by failing early in tun_set_iff() if
the file is detached. After this fix, there's no need to do the check again in
tun_set_iff(), so this patch removes it.

Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/tun.c