Skip to contentSkip to conversation

CVE-2022-50513: staging: rtl8723bs: fix a potential memory leak in rtw_init_cmd_priv()

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Oct 7, 2025

lore
Share & tools
lore
#0 lore raw

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

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

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

staging: rtl8723bs: fix a potential memory leak in rtw_init_cmd_priv()

In rtw_init_cmd_priv(), if pcmdpriv->rsp_allocated_buf is allocated in failure, then pcmdpriv->cmd_allocated_buf will be not properly released. Besides, considering there are only two error paths and the first one can directly return, so we do not need implicitly jump to the exit tag to execute the error handler.

So this patch added kfree(pcmdpriv->cmd_allocated_buf); on the error path to release the resource and simplified the return logic of rtw_init_cmd_priv(). As there is no proper device to test with, no runtime testing was performed.

The Linux kernel CVE team has assigned CVE-2022-50513 to this issue.

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

	Fixed in 5.4.220 with commit e5d8f05edb36fc4ab15beec62cb6ab62f5a60fe2
	Fixed in 5.10.150 with commit e6cc39db24a63f68314473621020ed8cad7be423
	Fixed in 5.15.75 with commit 39bef9c6a91bbb790d04c1347cfeae584541fb6a
	Fixed in 5.19.17 with commit a5be64ff6d21f7805a91e6d81f53fc19cd9f0fae
	Fixed in 6.0.3 with commit 8db6ca84eee0ac258706f3fca54f7c021cb159ef
	Fixed in 6.1 with commit 708056fba733a73d926772ea4ce9a42d240345da

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-2022-50513

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/staging/rtl8723bs/core/rtw_cmd.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/e5d8f05edb36fc4ab15beec62cb6ab62f5a60fe2
	https://git.kernel.org/stable/c/e6cc39db24a63f68314473621020ed8cad7be423
	https://git.kernel.org/stable/c/39bef9c6a91bbb790d04c1347cfeae584541fb6a
	https://git.kernel.org/stable/c/a5be64ff6d21f7805a91e6d81f53fc19cd9f0fae
	https://git.kernel.org/stable/c/8db6ca84eee0ac258706f3fca54f7c021cb159ef
	https://git.kernel.org/stable/c/708056fba733a73d926772ea4ce9a42d240345da