Subject: CVE-2021-47075: nvmet: fix memory leak in nvmet_alloc_ctrl()

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

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

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

nvmet: fix memory leak in nvmet_alloc_ctrl()

When creating ctrl in nvmet_alloc_ctrl(), if the cntlid_min is larger
than cntlid_max of the subsystem, and jumps to the
"out_free_changed_ns_list" label, but the ctrl->sqs lack of be freed.
Fix this by jumping to the "out_free_sqs" label.

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

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

	Issue introduced in 5.7 with commit 94a39d61f80f and fixed in 5.10.40 with commit 4720f29acb3f
	Issue introduced in 5.7 with commit 94a39d61f80f and fixed in 5.12.7 with commit afb680ed7ecb
	Issue introduced in 5.7 with commit 94a39d61f80f and fixed in 5.13 with commit fec356a61aa3

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-47075
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/nvme/target/core.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/4720f29acb3fe67aa8aa71e6b675b079d193aaeb
	https://git.kernel.org/stable/c/afb680ed7ecbb7fd66ddb43650e9b533fd8b4b9a
	https://git.kernel.org/stable/c/fec356a61aa3d3a66416b4321f1279e09e0f256f