Commit 2fc1ccae authored by sunshihao520's avatar sunshihao520 Committed by Tomasz Zawadzki
Browse files

lib/nvme: add value check to fix value inversion



When payload_size is 0, we may get wrong cdw10 because of the calculate: 0 - 1,
add value check to fix value inversion bug.

Signed-off-by: default avatarsunshihao <sunshihao@huawei.com>
Change-Id: I3bcd38ba981c854ff917282341d32aac47d22b76
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7443


Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatar <dongx.yi@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 32999ab9
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -988,7 +988,9 @@ nvme_ctrlr_cmd_directive(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
	cmd->opc = opc_type;
	cmd->nsid = nsid;

	if ((payload_size >> 2) > 0) {
		cmd->cdw10 = (payload_size >> 2) - 1;
	}
	cmd->cdw11_bits.directive.doper = doper;
	cmd->cdw11_bits.directive.dtype = dtype;
	cmd->cdw11_bits.directive.dspec = dspec;