Subject: CVE-2023-52662: drm/vmwgfx: fix a memleak in vmw_gmrid_man_get_node

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

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

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

drm/vmwgfx: fix a memleak in vmw_gmrid_man_get_node

When ida_alloc_max fails, resources allocated before should be freed,
including *res allocated by kmalloc and ttm_resource_init.

The Linux kernel CVE team has assigned CVE-2023-52662 to this issue.

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

	Issue introduced in 5.14 with commit d3bcb4b02fe9 and fixed in 5.15.153 with commit 03b1072616a8
	Issue introduced in 5.14 with commit d3bcb4b02fe9 and fixed in 6.1.83 with commit 40624af66747
	Issue introduced in 5.14 with commit d3bcb4b02fe9 and fixed in 6.6.23 with commit 83e0f220d1e9
	Issue introduced in 5.14 with commit d3bcb4b02fe9 and fixed in 6.7.11 with commit 6fc6233f6db1
	Issue introduced in 5.14 with commit d3bcb4b02fe9 and fixed in 6.8.2 with commit d1e546ab91c6
	Issue introduced in 5.14 with commit d3bcb4b02fe9 and fixed in 6.9 with commit 89709105a609

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-2023-52662
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/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.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/03b1072616a8f7d6e8594f643b416a9467c83fbf
	https://git.kernel.org/stable/c/40624af6674745e174c754a20d7c53c250e65e7a
	https://git.kernel.org/stable/c/83e0f220d1e992fa074157fcf14945bf170ffbc5
	https://git.kernel.org/stable/c/6fc6233f6db1579b69b54b44571f1a7fde8186e6
	https://git.kernel.org/stable/c/d1e546ab91c670e536a274a75481034ab7534876
	https://git.kernel.org/stable/c/89709105a6091948ffb6ec2427954cbfe45358ce