Skip to content

Commit f7c5234

Browse files
kyetdavejiang
authored andcommitted
cxl/core: Fix initialization of mbox_cmd.size_out in get event
Since mbox_cmd.size_out is overwritten with the actual output size in the function below, it needs to be initialized every time. cxl_internal_send_cmd -> __cxl_pci_mbox_send_cmd Problem scenario: 1) The size_out variable is initially set to the size of the mailbox. 2) Read an event. - size_out is set to 160 bytes(header 32B + one event 128B). - Two event are created while reading. 3) Read the new *two* events. - size_out is still set to 160 bytes. - Although the value of out_len is 288 bytes, only 160 bytes are copied from the mailbox register to the local variable. - record_count is set to 2. - Accessing records[1] will result in reading incorrect data. Fixes: 6ebe28f ("cxl/mem: Read, trace, and clear events on driver load") Tested-by: Ira Weiny <[email protected]> Reviewed-by: Ira Weiny <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Signed-off-by: Kwangjin Ko <[email protected]> Signed-off-by: Dave Jiang <[email protected]>
1 parent 5c88a9c commit f7c5234

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/cxl/core/mbox.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,13 +958,14 @@ static void cxl_mem_get_records_log(struct cxl_memdev_state *mds,
958958
.payload_in = &log_type,
959959
.size_in = sizeof(log_type),
960960
.payload_out = payload,
961-
.size_out = mds->payload_size,
962961
.min_out = struct_size(payload, records, 0),
963962
};
964963

965964
do {
966965
int rc, i;
967966

967+
mbox_cmd.size_out = mds->payload_size;
968+
968969
rc = cxl_internal_send_cmd(mds, &mbox_cmd);
969970
if (rc) {
970971
dev_err_ratelimited(dev,

0 commit comments

Comments
 (0)