public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs_spaceman: close open file for error case in openfile()
@ 2017-06-29 16:25 Bill O'Donnell
  2017-06-29 16:27 ` Darrick J. Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Bill O'Donnell @ 2017-06-29 16:25 UTC (permalink / raw)
  To: linux-xfs; +Cc: sandeen

openfile() fails to close the open file in one error case.
Add close(fd) to correct the condition.

Detected by CoverityScan, CID#1413770 (RESOURCE_LEAK)

Signed-off-by: Bill O'Donnell <billodo@redhat.com>
---
 spaceman/file.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/spaceman/file.c b/spaceman/file.c
index 4ab30900..4c13b4a8 100644
--- a/spaceman/file.c
+++ b/spaceman/file.c
@@ -79,6 +79,7 @@ openfile(
 		if (!fsp) {
 			fprintf(stderr, _("%s: cannot find mount point."),
 				path);
+			close(fd);
 			return -1;
 		}
 		memcpy(fs_path, fsp, sizeof(struct fs_path));
-- 
2.13.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-29 16:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-29 16:25 [PATCH] xfs_spaceman: close open file for error case in openfile() Bill O'Donnell
2017-06-29 16:27 ` Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox