diff mbox series

[ndctl,3/4] libndctl: Fix an unhandled return in ndctl_bus_poll_scrub_completion()

Message ID 20190510190839.29637-4-vishal.l.verma@intel.com (mailing list archive)
State Accepted
Commit df989d94bb8d05de747076677e608db971604691
Headers show
Series static analysis fixes | expand

Commit Message

Verma, Vishal L May 10, 2019, 7:08 p.m. UTC
Static analysis warns that we were not checking the return value from
the call to open(2) in ndctl_bus_poll_scrub_completion(). Add the
checking and error out for this case.

Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 ndctl/lib/libndctl.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c
index 4acfb03..81e1551 100644
--- a/ndctl/lib/libndctl.c
+++ b/ndctl/lib/libndctl.c
@@ -1306,6 +1306,8 @@  NDCTL_EXPORT int ndctl_bus_poll_scrub_completion(struct ndctl_bus *bus,
 	int fd = 0, rc;
 
 	fd = open(bus->scrub_path, O_RDONLY|O_CLOEXEC);
+	if (fd < 0)
+		return -errno;
 	memset(&fds, 0, sizeof(fds));
 	fds.fd = fd;
 	for (;;) {