Skip to content

Commit c2e5484

Browse files
committed
nvme: update device error handling for list-subsys
The list-subsys command does not properly check if the nvme device passed to the <device> option is a valid device or not. Fix the same. Signed-off-by: Martin George <[email protected]>
1 parent cba763f commit c2e5484

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

nvme.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3422,6 +3422,7 @@ static int list_subsys(int argc, char **argv, struct command *cmd,
34223422
struct plugin *plugin)
34233423
{
34243424
_cleanup_nvme_root_ nvme_root_t r = NULL;
3425+
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
34253426
nvme_print_flags_t flags;
34263427
const char *desc = "Retrieve information for subsystems";
34273428
nvme_scan_filter_t filter = NULL;
@@ -3459,12 +3460,10 @@ static int list_subsys(int argc, char **argv, struct command *cmd,
34593460
}
34603461

34613462
if (devname) {
3462-
int subsys_num;
3463+
err = parse_and_open(&dev, argc, argv, desc, opts);
3464+
if (err)
3465+
return err;
34633466

3464-
if (sscanf(devname, "nvme%dn%d", &subsys_num, &nsid) != 2) {
3465-
nvme_show_error("Invalid device name %s", devname);
3466-
return -EINVAL;
3467-
}
34683467
filter = nvme_match_device_filter;
34693468
}
34703469

0 commit comments

Comments
 (0)