Subject: CVE-2021-47545: perf hist: Fix memory leak of a perf_hpp_fmt

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

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

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

perf hist: Fix memory leak of a perf_hpp_fmt

perf_hpp__column_unregister() removes an entry from a list but doesn't
free the memory causing a memory leak spotted by leak sanitizer.

Add the free while at the same time reducing the scope of the function
to static.

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

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

	Fixed in 4.14.257 with commit c5c8a26c0dc6
	Fixed in 4.19.220 with commit 24a139c105fa
	Fixed in 5.4.164 with commit b380d09e44e8
	Fixed in 5.10.84 with commit a4c17ebdd624
	Fixed in 5.15.7 with commit 5b5c6f57a1f8
	Fixed in 5.16 with commit 0ca1f534a776

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-47545
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:
	tools/perf/ui/hist.c
	tools/perf/util/hist.h

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/c5c8a26c0dc69a400553245e92d741fe55f91095
	https://git.kernel.org/stable/c/24a139c105fa0f7f99888cf328bf6a02fc841675
	https://git.kernel.org/stable/c/b380d09e44e8479e71e3ae8446b515a5b3166244
	https://git.kernel.org/stable/c/a4c17ebdd6249cb4e061358d3693383f6628e069
	https://git.kernel.org/stable/c/5b5c6f57a1f81499db4c8ea597898cb1b87de0b6
	https://git.kernel.org/stable/c/0ca1f534a776cc7d42f2c33da4732b74ec2790cd