From: ZhaoJinming <zhaojinming@uniontech.com>
To: srinivas.pandruvada@linux.intel.com, hansg@kernel.org,
ilpo.jarvinen@linux.intel.com
Cc: platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org,
ZhaoJinming <zhaojinming@uniontech.com>,
stable@vger.kernel.org
Subject: [PATCH] platform/x86/intel/tpmi: Fix memory leak in mem_write() error path
Date: Tue, 19 May 2026 16:21:36 +0800 [thread overview]
Message-ID: <20260519082136.2999917-1-zhaojinming@uniontech.com> (raw)
In mem_write(), when the IS_ALIGNED() check fails, the function returns
-EINVAL directly without freeing the 'array' allocated by
parse_int_array_user(). This causes a memory leak.
Other error paths in the same function correctly use 'goto exit_write'
to free the array before returning. Fix this inconsistency by using
the same pattern for the alignment check.
Fixes: 8e0a2fc68ec3 ("platform/x86/intel/tpmi: Use 32 bit aligned address for debugfs mem write")
Cc: stable@vger.kernel.org
Signed-off-by: ZhaoJinming <zhaojinming@uniontech.com>
---
drivers/platform/x86/intel/vsec_tpmi.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/intel/vsec_tpmi.c b/drivers/platform/x86/intel/vsec_tpmi.c
index 16fd7aa41f20..2a428bfcb209 100644
--- a/drivers/platform/x86/intel/vsec_tpmi.c
+++ b/drivers/platform/x86/intel/vsec_tpmi.c
@@ -495,8 +495,10 @@ static ssize_t mem_write(struct file *file, const char __user *userbuf, size_t l
addr = array[2];
value = array[3];
- if (!IS_ALIGNED(addr, sizeof(u32)))
- return -EINVAL;
+ if (!IS_ALIGNED(addr, sizeof(u32))) {
+ ret = -EINVAL;
+ goto exit_write;
+ }
if (punit >= pfs->pfs_header.num_entries) {
ret = -EINVAL;
--
2.20.1
next reply other threads:[~2026-05-19 8:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 8:21 ZhaoJinming [this message]
2026-05-19 14:32 ` Ilpo Järvinen
2026-05-20 5:41 ` ZhaoJinming
2026-05-20 5:41 ` [PATCH 1/2] platform/x86/intel/tpmi: use cleanup helpers in mem_write() ZhaoJinming
2026-05-20 10:37 ` Ilpo Järvinen
2026-05-21 3:56 ` [PATCH] platform/x86/intel/tpmi: Fix memory leak in mem_write() error path ZhaoJinming
2026-05-21 3:56 ` [PATCH 1/2] platform/x86/intel/tpmi: use cleanup helpers in mem_write() ZhaoJinming
2026-05-21 12:58 ` Ilpo Järvinen
2026-05-21 13:13 ` 赵金明
2026-05-21 3:56 ` [PATCH 2/2] platform/x86/intel/tpmi: convert mutex in mem_write() to guard ZhaoJinming
2026-05-20 5:41 ` [PATCH 2/2] platform/x86/intel/tpmi: convert mutex lock/unlock " ZhaoJinming
2026-05-20 5:54 ` [PATCH 1/2] platform/x86/intel/tpmi: use cleanup helpers in mem_write() ZhaoJinming
2026-05-20 5:54 ` [PATCH 2/2] platform/x86/intel/tpmi: convert mutex lock/unlock in mem_write() to guard ZhaoJinming
2026-05-19 16:35 ` [PATCH] platform/x86/intel/tpmi: Fix memory leak in mem_write() error path srinivas pandruvada
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=20260519082136.2999917-1-zhaojinming@uniontech.com \
--to=zhaojinming@uniontech.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®