Skip to content

Commit e7a2936

Browse files
Yuuoniybp3tk0v
authored andcommitted
EDAC/highbank: Fix memory leak in highbank_mc_probe()
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: a1b01ed ("edac: add support for Calxeda highbank memory controller") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Andre Przywara <andre.przywara@arm.com> Link: https://lore.kernel.org/r/20221229054825.1361993-1-linmq006@gmail.com
1 parent e840774 commit e7a2936

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/edac/highbank_mc_edac.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,10 @@ static int highbank_mc_probe(struct platform_device *pdev)
174174
drvdata = mci->pvt_info;
175175
platform_set_drvdata(pdev, mci);
176176

177-
if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL))
178-
return -ENOMEM;
177+
if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) {
178+
res = -ENOMEM;
179+
goto free;
180+
}
179181

180182
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
181183
if (!r) {
@@ -243,6 +245,7 @@ static int highbank_mc_probe(struct platform_device *pdev)
243245
edac_mc_del_mc(&pdev->dev);
244246
err:
245247
devres_release_group(&pdev->dev, NULL);
248+
free:
246249
edac_mc_free(mci);
247250
return res;
248251
}

0 commit comments

Comments
 (0)