* [PATCH] EDAC/amd64: fix possible leak in hw_info_get()
@ 2022-11-10 2:52 Peng Wu
2022-11-10 21:36 ` Yazen Ghannam
0 siblings, 1 reply; 2+ messages in thread
From: Peng Wu @ 2022-11-10 2:52 UTC (permalink / raw)
To: yazen.ghannam, bp, mchehab, james.morse, rric
Cc: linux-edac, liwei391, Peng Wu
Add missing kfree() in an error path in hw_info_get()
to avoid a memory leak.
Fixes: 80355a3b2db9 ("EDAC/amd64: Gather hardware information early")
Signed-off-by: Peng Wu <wupeng58@huawei.com>
---
drivers/edac/amd64_edac.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 2f854feeeb23..b64b774eb974 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -4108,8 +4108,10 @@ static int hw_info_get(struct amd64_pvt *pvt)
}
ret = reserve_mc_sibling_devs(pvt, pci_id1, pci_id2);
- if (ret)
+ if (ret) {
+ kfree(pvt->umc);
return ret;
+ }
read_mc_regs(pvt);
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] EDAC/amd64: fix possible leak in hw_info_get()
2022-11-10 2:52 [PATCH] EDAC/amd64: fix possible leak in hw_info_get() Peng Wu
@ 2022-11-10 21:36 ` Yazen Ghannam
0 siblings, 0 replies; 2+ messages in thread
From: Yazen Ghannam @ 2022-11-10 21:36 UTC (permalink / raw)
To: Peng Wu; +Cc: bp, mchehab, james.morse, rric, linux-edac, liwei391
On Thu, Nov 10, 2022 at 02:52:56AM +0000, Peng Wu wrote:
> Add missing kfree() in an error path in hw_info_get()
> to avoid a memory leak.
>
> Fixes: 80355a3b2db9 ("EDAC/amd64: Gather hardware information early")
> Signed-off-by: Peng Wu <wupeng58@huawei.com>
> ---
> drivers/edac/amd64_edac.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
> index 2f854feeeb23..b64b774eb974 100644
> --- a/drivers/edac/amd64_edac.c
> +++ b/drivers/edac/amd64_edac.c
> @@ -4108,8 +4108,10 @@ static int hw_info_get(struct amd64_pvt *pvt)
> }
>
> ret = reserve_mc_sibling_devs(pvt, pci_id1, pci_id2);
> - if (ret)
> + if (ret) {
> + kfree(pvt->umc);
> return ret;
> + }
>
> read_mc_regs(pvt);
>
> --
Hi Peng Wu,
Thank you for your submisssion.
This is already handled in the error path.
If hw_info_get() fails, then we jump to the "err_enable" label in
probe_one_instance(). This calls hw_info_put() which frees the "umc" array.
Is there a case where this path isn't followed?
Thanks,
Yazen
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-10 21:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-10 2:52 [PATCH] EDAC/amd64: fix possible leak in hw_info_get() Peng Wu
2022-11-10 21:36 ` Yazen Ghannam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox