From: Kwangjin Ko <kwangjin.ko@sk.com>
To: dave@stgolabs.net, jonathan.cameron@huawei.com,
dave.jiang@intel.com, alison.schofield@intel.com,
vishal.l.verma@intel.com, ira.weiny@intel.com,
dan.j.williams@intel.com
Cc: linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel_team@skhynix.com
Subject: [PATCH 2/2] cxl/core: Fix incorrect array index in cxl_clear_event_record()
Date: Mon, 1 Apr 2024 18:10:56 +0900 [thread overview]
Message-ID: <20240401091057.1044-2-kwangjin.ko@sk.com> (raw)
In-Reply-To: <20240401091057.1044-1-kwangjin.ko@sk.com>
The variable 'i' should be incremented after dev_dbg(), or print
gen->hdr.handle instead. Otherwise, the handle value of the next loop
will be printed. Furthermore, in the final loop, accessing 'handles[i]'
will cause a buffer overflow.
Signed-off-by: Kwangjin Ko <kwangjin.ko@sk.com>
---
drivers/cxl/core/mbox.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
index a38531a055c8..84014aa01c95 100644
--- a/drivers/cxl/core/mbox.c
+++ b/drivers/cxl/core/mbox.c
@@ -913,9 +913,9 @@ static int cxl_clear_event_record(struct cxl_memdev_state *mds,
struct cxl_event_record_raw *raw = &get_pl->records[cnt];
struct cxl_event_generic *gen = &raw->event.generic;
- payload->handles[i++] = gen->hdr.handle;
dev_dbg(mds->cxlds.dev, "Event log '%d': Clearing %u\n", log,
- le16_to_cpu(payload->handles[i]));
+ le16_to_cpu(gen->hdr.handle));
+ payload->handles[i++] = gen->hdr.handle;
if (i == max_handles) {
payload->nr_recs = i;
--
2.34.1
next prev parent reply other threads:[~2024-04-01 9:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-01 9:10 [PATCH 1/2] cxl/core: Fix initialization of mbox_cmd.size_out in get event Kwangjin Ko
2024-04-01 9:10 ` Kwangjin Ko [this message]
2024-04-01 19:09 ` [PATCH 2/2] cxl/core: Fix incorrect array index in cxl_clear_event_record() Alison Schofield
2024-04-01 20:26 ` [PATCH 1/2] cxl/core: Fix initialization of mbox_cmd.size_out in get event Ira Weiny
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=20240401091057.1044-2-kwangjin.ko@sk.com \
--to=kwangjin.ko@sk.com \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=jonathan.cameron@huawei.com \
--cc=kernel_team@skhynix.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vishal.l.verma@intel.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