lkml.org 
[lkml]   [2024]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] cxl/core: Fix incorrect array index in cxl_clear_event_record()
Date
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

\
 
 \ /
  Last update: 2024-05-27 16:17    [W:0.047 / U:0.580 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site