Skip to content

Commit 4f1aa35

Browse files
yuzhenfschinadjbw
authored andcommitted
cxl/pmem: Use size_add() against integer overflow
"struct_size() + n" may cause a integer overflow, use size_add() to handle it. Signed-off-by: Yu Zhe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent 71ee71d commit 4f1aa35

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/cxl/pmem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static int cxl_pmem_set_config_data(struct cxl_dev_state *cxlds,
148148
return -EINVAL;
149149

150150
/* 4-byte status follows the input data in the payload */
151-
if (struct_size(cmd, in_buf, cmd->in_length) + 4 > buf_len)
151+
if (size_add(struct_size(cmd, in_buf, cmd->in_length), 4) > buf_len)
152152
return -EINVAL;
153153

154154
set_lsa =

0 commit comments

Comments
 (0)