From: Keith Busch Date: Fri, 23 Feb 2018 12:04:11 +0000 (-0700) Subject: Fix fabrics property commands X-Git-Tag: v1.6~74 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=0da7b3e198b45baa766a2b87e0fb687175dbe4a9;p=users%2Fsagi%2Fnvme-cli.git Fix fabrics property commands The code was casting pointers to fundamentally different types. Link: https://github.com/linux-nvme/nvme-cli/issues/310 Signed-off-by: Keith Busch --- diff --git a/nvme-ioctl.c b/nvme-ioctl.c index 95ebdfff..51664464 100644 --- a/nvme-ioctl.c +++ b/nvme-ioctl.c @@ -496,39 +496,30 @@ int nvme_set_feature(int fd, __u32 nsid, __u8 fid, __u32 value, __u32 cdw12, int nvme_property(int fd, __u8 fctype, __le32 off, __le64 *value, __u8 attrib) { int err; - struct nvmf_property_get_command *prop_get_cmd; - struct nvmf_property_set_command *prop_set_cmd; struct nvme_admin_cmd cmd = { .opcode = nvme_fabrics_command, + .cdw10 = attrib, + .cdw11 = off, }; if (!value) { errno = EINVAL; return -errno; } + if (fctype == nvme_fabrics_type_property_get){ - prop_get_cmd = (struct nvmf_property_get_command *)&cmd; - prop_get_cmd->fctype = nvme_fabrics_type_property_get; - prop_get_cmd->offset = off; - prop_get_cmd->attrib = attrib; - } - else if(fctype == nvme_fabrics_type_property_set) { - prop_set_cmd = (struct nvmf_property_set_command *)&cmd; - prop_set_cmd->fctype = nvme_fabrics_type_property_set; - prop_set_cmd->offset = off; - prop_set_cmd->attrib = attrib; - prop_set_cmd->value = *value; - } - else { + cmd.nsid = nvme_fabrics_type_property_get; + } else if(fctype == nvme_fabrics_type_property_set) { + cmd.nsid = nvme_fabrics_type_property_set; + cmd.cdw12 = *value; + } else { errno = EINVAL; return -errno; } err = nvme_submit_admin_passthru(fd, &cmd); - if (!err && fctype == nvme_fabrics_type_property_get) { + if (!err && fctype == nvme_fabrics_type_property_get) *value = cpu_to_le64(cmd.result); - } - return err; }