]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
fabrics: ignore hostnqn file if its empty
authorSagi Grimberg <sagi@grimberg.me>
Wed, 12 Feb 2020 20:01:57 +0000 (12:01 -0800)
committerKeith Busch <kbusch@kernel.org>
Fri, 14 Feb 2020 14:28:46 +0000 (23:28 +0900)
If we read an empty string from /etc/nvme/hostnqn we should
ignore it instead of passing an empty string to the
driver resulting in the error:

nvme_fabrics: unknown parameter or missing value 'hostnqn=' in ctrl creation request

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Keith Busch <kbusch@kernel.org>
fabrics.c

index 57625cd379112048294aa50ad4bd0f27a564852a..98a42783079754fe0342db6ea0954e368e567e80 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -672,7 +672,8 @@ static char *hostnqn_read_file(void)
        if (f == NULL)
                return false;
 
-       if (fgets(hostnqn, sizeof(hostnqn), f) == NULL)
+       if (fgets(hostnqn, sizeof(hostnqn), f) == NULL ||
+           !strlen(hostnqn))
                goto out;
 
        ret = strndup(hostnqn, strcspn(hostnqn, "\n"));