From bc343b3c4d16bd02598ec54105532e766cc1a22b Mon Sep 17 00:00:00 2001 From: Martin George Date: Wed, 9 Jul 2025 15:04:16 +0530 Subject: [PATCH 1/2] netapp-ontapdev: update invalid device handling Error out with an appropriate message if an invalid or non-existent device is passed to the NetApp ontapdevices plugin. Signed-off-by: Martin George --- plugins/netapp/netapp-nvme.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/netapp/netapp-nvme.c b/plugins/netapp/netapp-nvme.c index ef4d8fcdab..72a3e30a85 100644 --- a/plugins/netapp/netapp-nvme.c +++ b/plugins/netapp/netapp-nvme.c @@ -1023,11 +1023,19 @@ static int netapp_ontapdevices(int argc, char **argv, struct command *command, if (devname) { int subsys_num, nsid; + struct stat st; + char path[512]; if (sscanf(devname, "nvme%dn%d", &subsys_num, &nsid) != 2) { fprintf(stderr, "Invalid device name %s\n", devname); return -EINVAL; } + + sprintf(path, "/dev/%s", devname); + if (stat(path, &st) != 0) { + fprintf(stderr, "%s does not exist\n", path); + return -EINVAL; + } } num = scandir(dev_path, &devices, netapp_nvme_filter, alphasort); From 0edb05b947dd7ac251a8956334ff1a17d3a80a58 Mon Sep 17 00:00:00 2001 From: Martin George Date: Wed, 9 Jul 2025 15:31:55 +0530 Subject: [PATCH 2/2] netapp-smdev: update invalid device handling Error out with an appropriate message if an invalid or non-existent device is passed to the NetApp smdevices plugin. Signed-off-by: Martin George --- plugins/netapp/netapp-nvme.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/netapp/netapp-nvme.c b/plugins/netapp/netapp-nvme.c index 72a3e30a85..b82ef5eb62 100644 --- a/plugins/netapp/netapp-nvme.c +++ b/plugins/netapp/netapp-nvme.c @@ -931,11 +931,19 @@ static int netapp_smdevices(int argc, char **argv, struct command *command, if (devname) { int subsys_num, nsid; + struct stat st; + char path[512]; if (sscanf(devname, "nvme%dn%d", &subsys_num, &nsid) != 2) { fprintf(stderr, "Invalid device name %s\n", devname); return -EINVAL; } + + sprintf(path, "/dev/%s", devname); + if (stat(path, &st) != 0) { + fprintf(stderr, "%s does not exist\n", path); + return -EINVAL; + } } smdevices = calloc(num, sizeof(*smdevices));