Skip to content

Commit

Permalink
nvme: return -ENXIO value to open device if errno not set
Browse files Browse the repository at this point in the history
The APIs may not set errno so set errno to ENXIO before the device open.

Signed-off-by: Tokunori Ikegami <[email protected]>
  • Loading branch information
ikegami-t committed Jul 22, 2024
1 parent ede9a5f commit 6bff9f4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,14 @@ static int get_dev(struct nvme_dev **dev, int argc, char **argv, int flags)
return ret;

devname = argv[optind];
errno = ENXIO;

if (!strncmp(devname, "mctp:", strlen("mctp:")))
ret = open_dev_mi_mctp(dev, devname);
else
ret = open_dev_direct(dev, devname, flags);

return ret != 0 ? -errno : 0;
return ret ? -errno : 0;
}

static int parse_args(int argc, char *argv[], const char *desc,
Expand Down

0 comments on commit 6bff9f4

Please sign in to comment.