Skip to content

Commit

Permalink
nvme: fix overflow possiblity
Browse files Browse the repository at this point in the history
The implicit type conversion will expand both operands to the type
int and not unsigned long long as the result expects. Promote
the first operand to the target type. Obviously the multiplication
can still overflow, but this is a different problem.

Signed-off-by: Steven Seungcheol Lee <[email protected]>
[dwagner: added commit message]
Signed-off-by: Daniel Wagner <[email protected]>
  • Loading branch information
sc108-lee authored and igaw committed Nov 3, 2023
1 parent f471d6a commit 77e0ba2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -7317,7 +7317,7 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char
nblocks = ((buffer_size + (logical_block_size - 1)) / logical_block_size) - 1;

/* Update the data size based on the required block count */
buffer_size = (nblocks + 1) * logical_block_size;
buffer_size = ((unsigned long long)nblocks + 1) * logical_block_size;
}

buffer = nvme_alloc_huge(buffer_size, &huge);
Expand Down

0 comments on commit 77e0ba2

Please sign in to comment.