public inbox for linux-edac@vger.kernel.org
 help / color / mirror / Atom feed
From: Peng Wu <wupeng58@huawei.com>
To: <yazen.ghannam@amd.com>, <bp@alien8.de>, <mchehab@kernel.org>,
	<james.morse@arm.com>, <rric@kernel.org>
Cc: <linux-edac@vger.kernel.org>, <liwei391@huawei.com>,
	Peng Wu <wupeng58@huawei.com>
Subject: [PATCH] EDAC/amd64: fix possible leak in hw_info_get()
Date: Thu, 10 Nov 2022 02:52:56 +0000	[thread overview]
Message-ID: <20221110025256.37599-1-wupeng58@huawei.com> (raw)

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


             reply	other threads:[~2022-11-10  2:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10  2:52 Peng Wu [this message]
2022-11-10 21:36 ` [PATCH] EDAC/amd64: fix possible leak in hw_info_get() Yazen Ghannam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221110025256.37599-1-wupeng58@huawei.com \
    --to=wupeng58@huawei.com \
    --cc=bp@alien8.de \
    --cc=james.morse@arm.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=liwei391@huawei.com \
    --cc=mchehab@kernel.org \
    --cc=rric@kernel.org \
    --cc=yazen.ghannam@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox