tun.c (6f4c930e02355664d89c976eccea5d999a90de16) tun.c (11fc7d5a0a2d458cae8ce5d5ee3ebfdabe2cb35a)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * TUN - Universal TUN/TAP device driver.
4 * Copyright (C) 1999-2002 Maxim Krasnyansky <maxk@qualcomm.com>
5 *
6 * $Id: tun.c,v 1.15 2002/03/01 02:44:24 maxk Exp $
7 */
8

--- 2276 unchanged lines hidden (view full) ---

2285 return 0;
2286}
2287
2288static void tun_free_netdev(struct net_device *dev)
2289{
2290 struct tun_struct *tun = netdev_priv(dev);
2291
2292 BUG_ON(!(list_empty(&tun->disabled)));
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * TUN - Universal TUN/TAP device driver.
4 * Copyright (C) 1999-2002 Maxim Krasnyansky <maxk@qualcomm.com>
5 *
6 * $Id: tun.c,v 1.15 2002/03/01 02:44:24 maxk Exp $
7 */
8

--- 2276 unchanged lines hidden (view full) ---

2285 return 0;
2286}
2287
2288static void tun_free_netdev(struct net_device *dev)
2289{
2290 struct tun_struct *tun = netdev_priv(dev);
2291
2292 BUG_ON(!(list_empty(&tun->disabled)));
2293
2293 free_percpu(tun->pcpu_stats);
2294 free_percpu(tun->pcpu_stats);
2295 /* We clear pcpu_stats so that tun_set_iff() can tell if
2296 * tun_free_netdev() has been called from register_netdevice().
2297 */
2298 tun->pcpu_stats = NULL;
2299
2294 tun_flow_uninit(tun);
2295 security_tun_dev_free_security(tun->security);
2296 __tun_set_ebpf(tun, &tun->steering_prog, NULL);
2297 __tun_set_ebpf(tun, &tun->filter_prog, NULL);
2298}
2299
2300static void tun_setup(struct net_device *dev)
2301{

--- 552 unchanged lines hidden (view full) ---

2854 if (netif_running(tun->dev))
2855 netif_tx_wake_all_queues(tun->dev);
2856
2857 strcpy(ifr->ifr_name, tun->dev->name);
2858 return 0;
2859
2860err_detach:
2861 tun_detach_all(dev);
2300 tun_flow_uninit(tun);
2301 security_tun_dev_free_security(tun->security);
2302 __tun_set_ebpf(tun, &tun->steering_prog, NULL);
2303 __tun_set_ebpf(tun, &tun->filter_prog, NULL);
2304}
2305
2306static void tun_setup(struct net_device *dev)
2307{

--- 552 unchanged lines hidden (view full) ---

2860 if (netif_running(tun->dev))
2861 netif_tx_wake_all_queues(tun->dev);
2862
2863 strcpy(ifr->ifr_name, tun->dev->name);
2864 return 0;
2865
2866err_detach:
2867 tun_detach_all(dev);
2862 /* register_netdevice() already called tun_free_netdev() */
2863 goto err_free_dev;
2868 /* We are here because register_netdevice() has failed.
2869 * If register_netdevice() already called tun_free_netdev()
2870 * while dealing with the error, tun->pcpu_stats has been cleared.
2871 */
2872 if (!tun->pcpu_stats)
2873 goto err_free_dev;
2864
2865err_free_flow:
2866 tun_flow_uninit(tun);
2867 security_tun_dev_free_security(tun->security);
2868err_free_stat:
2869 free_percpu(tun->pcpu_stats);
2870err_free_dev:
2871 free_netdev(dev);

--- 868 unchanged lines hidden ---
2874
2875err_free_flow:
2876 tun_flow_uninit(tun);
2877 security_tun_dev_free_security(tun->security);
2878err_free_stat:
2879 free_percpu(tun->pcpu_stats);
2880err_free_dev:
2881 free_netdev(dev);

--- 868 unchanged lines hidden ---