Message ID | 20221110025256.37599-1-wupeng58@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | EDAC/amd64: fix possible leak in hw_info_get() | expand |
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
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);
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(-)