Commit 475619cd authored by Miaoqian Lin's avatar Miaoqian Lin Committed by Xiangwei Li
Browse files

EDAC/highbank: Fix memory leak in highbank_mc_probe()

stable inclusion
from stable-v4.19.272
commit 0db40e23b56d217eebd385bebb64057ef764b2c7
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBWVWI
CVE: CVE-2022-49757

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0db40e23b56d217eebd385bebb64057ef764b2c7



--------------------------------

[ Upstream commit e7a29365 ]

When devres_open_group() fails, it returns -ENOMEM without freeing memory
allocated by edac_mc_alloc().

Call edac_mc_free() on the error handling path to avoid a memory leak.

  [ bp: Massage commit message. ]

Fixes: a1b01edb ("edac: add support for Calxeda highbank memory controller")
Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: default avatarAndre Przywara <andre.przywara@arm.com>
Link: https://lore.kernel.org/r/20221229054825.1361993-1-linmq006@gmail.com


Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarXiangwei Li <liwei728@huawei.com>
parent 7951fd32
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -185,8 +185,10 @@ static int highbank_mc_probe(struct platform_device *pdev)
	drvdata = mci->pvt_info;
	platform_set_drvdata(pdev, mci);

	if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL))
		return -ENOMEM;
	if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) {
		res = -ENOMEM;
		goto free;
	}

	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!r) {
@@ -254,6 +256,7 @@ static int highbank_mc_probe(struct platform_device *pdev)
	edac_mc_del_mc(&pdev->dev);
err:
	devres_release_group(&pdev->dev, NULL);
free:
	edac_mc_free(mci);
	return res;
}