Message ID | 20200722052655.21296-3-vishal.l.verma@intel.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 560a1bf273ede58886a9aab02aa077deddc13daa |
Headers | show |
Series | misc fixes and cleanup | expand |
diff --git a/ndctl/namespace.c b/ndctl/namespace.c index 8aa5a42..e734248 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -1969,7 +1969,7 @@ static int file_write_infoblock(const char *path) free(buf); out: - if (fd > 0 && fd != STDOUT_FILENO) + if (fd >= 0 && fd != STDOUT_FILENO) close(fd); return rc; }
Static analysis showed that we might leak 'fd' in the given function. Fix the error path to close(fd) if 'fd >= 0' rather than just 'fd > 0'. Fixes: 7787807bcffe ("ndctl/namespace: Add write-infoblock command") Cc: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> --- ndctl/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)