Skip to content

Commit a0bc6b8

Browse files
committed
nvme: dsm: make context atttribute optional again
The context attribute are optional, thus relax the 'valid range' check. Fixes: 0841ca0 ("ioctl: fix dms command") Signed-off-by: Daniel Wagner <[email protected]>
1 parent 7c0f3fd commit a0bc6b8

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

nvme.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7351,11 +7351,12 @@ static int dsm(int argc, char **argv, struct command *acmd, struct plugin *plugi
73517351
nc = argconfig_parse_comma_sep_array_u32(cfg.ctx_attrs, ctx_attrs, ARRAY_SIZE(ctx_attrs));
73527352
nb = argconfig_parse_comma_sep_array_u32(cfg.blocks, nlbs, ARRAY_SIZE(nlbs));
73537353
ns = argconfig_parse_comma_sep_array_u64(cfg.slbas, slbas, ARRAY_SIZE(slbas));
7354-
if (nc != nb || nb != ns) {
7354+
if ((nb != ns) ||
7355+
(argconfig_parse_seen(opts, "ctx-attrs") && nb != nc)) {
73557356
nvme_show_error("No valid range definition provided");
73567357
return -EINVAL;
73577358
}
7358-
if (!nc || nc > 256) {
7359+
if (!nb || nb > 256) {
73597360
nvme_show_error("No range definition provided");
73607361
return -EINVAL;
73617362
}
@@ -7373,13 +7374,13 @@ static int dsm(int argc, char **argv, struct command *acmd, struct plugin *plugi
73737374
cfg.idr = NVME_GET(cfg.cdw11, DSM_CDW11_IDR);
73747375
}
73757376

7376-
dsm = nvme_alloc(sizeof(*dsm) * nc);
7377+
dsm = nvme_alloc(sizeof(*dsm) * nb);
73777378
if (!dsm)
73787379
return -ENOMEM;
73797380

7380-
nvme_init_dsm_range(dsm, ctx_attrs, nlbs, slbas, nc);
7381-
nvme_init_dsm(&cmd, cfg.namespace_id, nc, cfg.idr, cfg.idw, cfg.ad, dsm,
7382-
sizeof(*dsm) * nc);
7381+
nvme_init_dsm_range(dsm, ctx_attrs, nlbs, slbas, nb);
7382+
nvme_init_dsm(&cmd, cfg.namespace_id, nb, cfg.idr, cfg.idw, cfg.ad, dsm,
7383+
sizeof(*dsm) * nb);
73837384
err = nvme_submit_io_passthru(hdl, &cmd, NULL);
73847385
if (err < 0)
73857386
nvme_show_error("data-set management: %s", nvme_strerror(err));

0 commit comments

Comments
 (0)