Static analysis reports that we leak the 'fd' in the above function. Fix by adding a proper cleanup path that closes it.
Cc: Keith Busch <[email protected]> Fixes: dd8e6ff9ab00 ("ndctl: Create ndctl udev rules for dirty shutdown") Signed-off-by: Vishal Verma <[email protected]> --- ndctl/ndctl-udev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ndctl/ndctl-udev.c b/ndctl/ndctl-udev.c index 2b4d067..7b174b6 100644 --- a/ndctl/ndctl-udev.c +++ b/ndctl/ndctl-udev.c @@ -110,10 +110,13 @@ static void save_unsafe_shutdown_count(struct ndctl_dimm *dimm, goto free_usc; if (snprintf(count, sizeof(count), "%u\n", shutdown) < 0) - goto free_usc; + goto close_fd; if (write(fd, count, strlen(count)) < 0) - goto free_usc; + goto close_fd; + + close_fd: + close(fd); free_usc: free(usc); free_path: -- 2.14.4 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
