Subject: CVE-2021-47311: net: qcom/emac: fix UAF in emac_remove

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

net: qcom/emac: fix UAF in emac_remove

adpt is netdev private data and it cannot be
used after free_netdev() call. Using adpt after free_netdev()
can cause UAF bug. Fix it by moving free_netdev() at the end of the
function.

The Linux kernel CVE team has assigned CVE-2021-47311 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 4.9 with commit 54e19bc74f33 and fixed in 4.9.277 with commit 4d04a42b926e
	Issue introduced in 4.9 with commit 54e19bc74f33 and fixed in 4.14.241 with commit b1e091331920
	Issue introduced in 4.9 with commit 54e19bc74f33 and fixed in 4.19.199 with commit 11e9d163d631
	Issue introduced in 4.9 with commit 54e19bc74f33 and fixed in 5.4.135 with commit 2b70ca92847c
	Issue introduced in 4.9 with commit 54e19bc74f33 and fixed in 5.10.53 with commit b560521eca03
	Issue introduced in 4.9 with commit 54e19bc74f33 and fixed in 5.13.5 with commit 8a225a6e07a5
	Issue introduced in 4.9 with commit 54e19bc74f33 and fixed in 5.14 with commit ad297cd2db89

Please see https://www.kernel.org for a full list of currently supported
kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to
older supported kernel versions.  The official CVE entry at
	https://cve.org/CVERecord/?id=CVE-2021-47311
will be updated if fixes are backported, please check that for the most
up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
	drivers/net/ethernet/qualcomm/emac/emac.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest
stable kernel version for this, and many other bugfixes.  Individual
changes are never tested alone, but rather are part of a larger kernel
release.  Cherry-picking individual commits is not recommended or
supported by the Linux kernel community at all.  If however, updating to
the latest release is impossible, the individual changes to resolve this
issue can be found at these commits:
	https://git.kernel.org/stable/c/4d04a42b926e682140776e54188f4a44f1f01a81
	https://git.kernel.org/stable/c/b1e091331920f8fbfc747dcbd16263fcd71abb2d
	https://git.kernel.org/stable/c/11e9d163d631198bb3eb41a677a61b499516c0f7
	https://git.kernel.org/stable/c/2b70ca92847c619d6264c7372ef74fcbfd1e048c
	https://git.kernel.org/stable/c/b560521eca03d0a2db6093a5a632cbdd0a0cf833
	https://git.kernel.org/stable/c/8a225a6e07a57a1538d53637cb3d82bd3e477839
	https://git.kernel.org/stable/c/ad297cd2db8953e2202970e9504cab247b6c7cb4