Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 2bb6ec6

Browse files
Arun Thomas KaringadaJuston Li
Arun Thomas Karingada
authored and
Juston Li
committed
Fixed logic of rounding up the output/input payload size passed to windows IOCTL
Signed-off-by: Arun Thomas Karingada <[email protected]>
1 parent 6f7254d commit 2bb6ec6

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/lib/win_scm2_ioctl_passthrough.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,16 @@ int win_scm2_ioctl_passthrough_cmd(unsigned short nfit_handle,
4949
*p_dsm_status = 0;
5050
CR_DSM_PASS_THROUGH_IOCTL ioctl_data;
5151

52-
// Because the CR_DSM_PASS_THROUGH_IOCTL struct has a byte for the input and output payloads
52+
// Because the CR_DSM_PASS_THROUGH_IOCTL struct has a byte for the input and output payloads
5353
// already, we need to subtract those bytes from the total buffer size
54-
ioctl_data.InputDataSize = sizeof (NVDIMM_PASSTHROUGH_IN) +
55-
input_payload_size - 1; // minus 1 byte no padding cause the struct is packed
56-
if (ioctl_data.InputDataSize < 12)
57-
ioctl_data.InputDataSize = 12; // Microsoft driver expects 12 bytes
58-
59-
ioctl_data.OutputDataSize = sizeof (NVDIMM_PASSTHROUGH_OUT) +
60-
output_payload_size - 1; // minus 1 byte no padding cause the struct is packed
61-
if(ioctl_data.OutputDataSize < 12)
62-
ioctl_data.OutputDataSize = 12; // Microsoft driver expects 12 bytes
54+
ioctl_data.InputDataSize = sizeof(NVDIMM_PASSTHROUGH_IN) +
55+
input_payload_size - 1; // minus 1 byte no padding cause the struct is packed
56+
if (input_payload_size == 0)
57+
ioctl_data.InputDataSize += 4; // Microsoft driver expects 12 bytes
58+
ioctl_data.OutputDataSize = sizeof(NVDIMM_PASSTHROUGH_OUT) +
59+
output_payload_size - 1; // minus 1 byte no padding cause the struct is packed
60+
if (output_payload_size == 0)
61+
ioctl_data.OutputDataSize += 4; // Microsoft driver expects 12 bytes
6362

6463
SCM_LOG_INFO_F("buf_size (%xh, %xh): in %d, out %d", op_code, sub_op_code,
6564
(int)ioctl_data.InputDataSize, (int)ioctl_data.OutputDataSize);

0 commit comments

Comments
 (0)