From b627cd1c208083648be4ca8810539d555580571a Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Thu, 30 May 2019 15:07:39 +0000 Subject: [PATCH] Pass data pointers to the driver in way in expects. Probably due to historical reasons the driver uses In/Out arguments in odd way. While this tool still never uses Out arguments to see that, make the code to not trigger EINVAL in possible future uses. MFC after: 2 weeks --- usr.sbin/mpsutil/mps_cmd.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/usr.sbin/mpsutil/mps_cmd.c b/usr.sbin/mpsutil/mps_cmd.c index 8e1e431d65f3..60c0a60b006b 100644 --- a/usr.sbin/mpsutil/mps_cmd.c +++ b/usr.sbin/mpsutil/mps_cmd.c @@ -651,27 +651,32 @@ mps_pass_command(int fd, void *req, uint32_t req_len, void *reply, { struct mprs_pass_thru pass; + bzero(&pass, sizeof(pass)); pass.PtrRequest = (uint64_t)(uintptr_t)req; pass.PtrReply = (uint64_t)(uintptr_t)reply; - pass.PtrData = (uint64_t)(uintptr_t)data_in; - pass.PtrDataOut = (uint64_t)(uintptr_t)data_out; pass.RequestSize = req_len; pass.ReplySize = reply_len; - pass.DataSize = datain_len; - pass.DataOutSize = dataout_len; if (datain_len && dataout_len) { + pass.PtrData = (uint64_t)(uintptr_t)data_in; + pass.PtrDataOut = (uint64_t)(uintptr_t)data_out; + pass.DataSize = datain_len; + pass.DataOutSize = dataout_len; if (is_mps) { pass.DataDirection = MPS_PASS_THRU_DIRECTION_BOTH; } else { pass.DataDirection = MPR_PASS_THRU_DIRECTION_BOTH; } } else if (datain_len) { + pass.PtrData = (uint64_t)(uintptr_t)data_in; + pass.DataSize = datain_len; if (is_mps) { pass.DataDirection = MPS_PASS_THRU_DIRECTION_READ; } else { pass.DataDirection = MPR_PASS_THRU_DIRECTION_READ; } } else if (dataout_len) { + pass.PtrData = (uint64_t)(uintptr_t)data_out; + pass.DataSize = dataout_len; if (is_mps) { pass.DataDirection = MPS_PASS_THRU_DIRECTION_WRITE; } else {