Blob Blame History Raw
From 22c19f6a5b58ad9ce99d2c2a95239eab911d908e Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 22 Jun 2021 13:40:23 +0200
Subject: [PATCH] nvme-ioctl: return -1 on failure from nvme_get_nsid()

If the call to 'fstat' fails we should be returning '-1' (as the
errno is already set by fstat()) to be compliant with the return
values from 'ioctl()'.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 nvme-ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nvme-ioctl.c b/nvme-ioctl.c
index cc12ae6..64152b1 100644
--- a/nvme-ioctl.c
+++ b/nvme-ioctl.c
@@ -68,7 +68,7 @@ int nvme_get_nsid(int fd)
 	int err = fstat(fd, &nvme_stat);
 
 	if (err < 0)
-		return -errno;
+		return err;
 
 	return ioctl(fd, NVME_IOCTL_ID);
 }
-- 
2.27.0