Subject: CVE-2021-47364: comedi: Fix memory leak in compat_insnlist()

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

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

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

comedi: Fix memory leak in compat_insnlist()

`compat_insnlist()` handles the 32-bit version of the `COMEDI_INSNLIST`
ioctl (whenwhen `CONFIG_COMPAT` is enabled).  It allocates memory to
temporarily hold an array of `struct comedi_insn` converted from the
32-bit version in user space.  This memory is only being freed if there
is a fault while filling the array, otherwise it is leaked.

Add a call to `kfree()` to fix the leak.

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

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

	Issue introduced in 5.8 with commit b8d47d881305 and fixed in 5.10.70 with commit 8d6a21e4cd6a
	Issue introduced in 5.8 with commit b8d47d881305 and fixed in 5.14.9 with commit f217b6c1e28e
	Issue introduced in 5.8 with commit b8d47d881305 and fixed in 5.15 with commit bb509a6ffed2

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-47364
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/comedi/comedi_fops.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/8d6a21e4cd6a319b0662cbe4ad6199e276ac776a
	https://git.kernel.org/stable/c/f217b6c1e28ed0b353634ce4d92a155b80bd1671
	https://git.kernel.org/stable/c/bb509a6ffed2c8b0950f637ab5779aa818ed1596