@@ -111,8 +111,7 @@ NDCTL_EXPORT struct ndctl_cmd *ndctl_bus_cmd_new_ars_status(struct ndctl_cmd *ar
return NULL;
}
- size = sizeof(*cmd) + sizeof(struct nd_cmd_ars_status) +
- ars_cap_cmd->max_ars_out;
+ size = sizeof(*cmd) + ars_cap_cmd->max_ars_out;
cmd = calloc(1, size);
if (!cmd)
return NULL;
@@ -123,6 +122,7 @@ NDCTL_EXPORT struct ndctl_cmd *ndctl_bus_cmd_new_ars_status(struct ndctl_cmd *ar
cmd->size = size;
cmd->status = 1;
cmd->firmware_status = &cmd->ars_status->status;
+ cmd->ars_status->out_length = ars_cap_cmd->max_ars_out;
return cmd;
}
@@ -1607,9 +1607,10 @@ static int check_ars_cap(struct ndctl_bus *bus, struct ndctl_dimm *dimm,
return rc;
}
- if (ndctl_cmd_ars_cap_get_size(cmd) != 256) {
- fprintf(stderr, "%s: bus: %s expect size: %d got: %d\n",
- __func__, ndctl_bus_get_provider(bus), 256,
+ if (ndctl_cmd_ars_cap_get_size(cmd) < sizeof(struct nd_cmd_ars_status)) {
+ fprintf(stderr, "%s: bus: %s expect size >= %zd got: %d\n",
+ __func__, ndctl_bus_get_provider(bus),
+ sizeof(struct nd_cmd_ars_status),
ndctl_cmd_ars_cap_get_size(cmd));
ndctl_cmd_unref(cmd);
return -ENXIO;
The ars_cap command indicates the buffer size we need to prepare for ars_status commands. The kernel reads the ars_status.out_length field to validate how much output buffer space is available. The ndctl_bus_cmd_new_ars_status() helper was neglecting to set that size. It was also misinterpreting the value of ars_cap.max_ars_out. That value is the total output data size of an ars_status command, not incremental to the base size of a ars_status command. Cc: Vishal Verma <vishal.l.verma@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- lib/libndctl-ars.c | 4 ++-- test/libndctl.c | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-)