net: 8021q: Fix one possible panic caused by BUG_ON in free_netdev
Gao Feng authored
[ Upstream commit 9745e362 ]

The register_vlan_device would invoke free_netdev directly, when
register_vlan_dev failed. It would trigger the BUG_ON in free_netdev
if the dev was already registered. In this case, the netdev would be
freed in netdev_run_todo later.

So add one condition check now. Only when dev is not registered, then
free it directly.

The following is the part coredump when netdev_upper_dev_link failed
in register_vlan_dev. I removed the lines which are too long.

[  411.237457] ------------[ cut here ]------------
[  411.237458] kernel BUG at net/core/dev.c:7998!
[  411.237484] invalid opcode: 0000 [#1] SMP
[  411.237705]  [last unloaded: 8021q]
[  411.237718] CPU: 1 PID: 12845 Comm: vconfig Tainted: G            E   4.12.0-rc5+ #6
[  411.237737] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 07/02/2015
[  411.237764] task: ffff9cbeb6685580...
16c4d1be
Name Last commit Last update
Documentation mm: larger stack guard gap, between vmas
arch arm64/vdso: Fix nsec handling for CLOCK_MONOTONIC_RAW
block partitions/msdos: FreeBSD UFS2 file systems are not recognized
certs certs: Add a secondary system keyring that can be added to dynamically
crypto crypto: gcm - wait for crypto op not signal safe
drivers net/mlx5e: Fix timestamping capabilities reporting
firmware WHENCE: use https://linuxtv.org for LinuxTV URLs
fs CIFS: Fix some return values in case of error in 'crypt_message'
include net: ipv6: Release route when device is unregistering
init initramfs: avoid "label at end of compound statement" error
ipc Merge branch 'WIP.sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
kernel time: Fix CLOCK_MONOTONIC_RAW sub-nanosecond accounting
lib lib/cmdline.c: fix get_options() overflow while parsing ranges
mm mm: fix new crash in unmapped_area_topdown()
net net: 8021q: Fix one possible panic caused by BUG_ON in free_netdev
samples statx: Include a mask for stx_attributes in struct statx
scripts Merge tag 'kbuild-fixes-v4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
security selinux: fix double free in selinux_parse_opts_str()
sound ALSA: hda - Apply quirks to Broxton-T, too
tools perf probe: Fix probe definition for inlined functions
usr kbuild: initramfs cleanup, set target from Kconfig
virt KVM: arm/arm64: vgic-v3: Do not use Active+Pending state for a HW interrupt
.cocciconfig scripts: add Linux .cocciconfig for coccinelle
.get_maintainer.ignore Add hch to .get_maintainer.ignore
.gitattributes .gitattributes: set git diff driver for C source code files
.gitignore Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
.mailmap mailmap: add Martin Kepplinger's email
COPYING [PATCH] update FSF address in COPYING
CREDITS MAINTAINERS: Remove old e-mail address
Kbuild scripts/gdb: provide linux constants
Kconfig kbuild: migrate all arch to the kconfig mainmenu upgrade
MAINTAINERS bpf, doc: update bpf maintainers entry
Makefile Linux 4.11.8
README README: add a new README file, pointing to the Documentation/
Linux kernel
============

This file was moved to Documentation/admin-guide/README.rst

Please notice that there are several guides for kernel developers and users.
These guides can be rendered in a number of formats, like HTML and PDF.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.
See Documentation/00-INDEX for a list of what is contained in each file.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.