[PATCH] nvmet-tcp: fix data digest pointer calculation

Sagi Grimberg sagi at grimberg.me
Wed Oct 27 00:11:01 PDT 2021


>> exp_ddgst is of type __le32, &cmd->exp_ddgst + cmd->offset
>> increases &cmd->exp_ddgst by 4 * cmd->offset, fix this by
>> type casting &cmd->exp_ddgst to u8 *.
>>
>> Fixes: 872d26a391da ("nvmet-tcp: add NVMe over TCP target driver")
>> Signed-off-by: Varun Prakash <varun at chelsio.com>
>> ---
>>   drivers/nvme/target/tcp.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
>> index 07ee347..d641bfa 100644
>> --- a/drivers/nvme/target/tcp.c
>> +++ b/drivers/nvme/target/tcp.c
>> @@ -702,7 +702,7 @@ static int nvmet_try_send_ddgst(struct nvmet_tcp_cmd *cmd, bool last_in_batch)
>>   	struct nvmet_tcp_queue *queue = cmd->queue;
>>   	struct msghdr msg = { .msg_flags = MSG_DONTWAIT };
>>   	struct kvec iov = {
>> -		.iov_base = &cmd->exp_ddgst + cmd->offset,
>> +		.iov_base = (u8 *)&cmd->exp_ddgst + cmd->offset,
> 
> Wouldn't be the better fix to divide cmd->offset by 4 instead of the
> casts?  I can fix this up inline if that is ok.

Don't really mind, what makes it a better fix?



More information about the Linux-nvme mailing list