Skip to contentSkip to conversation

xfs_spaceman: close open file for error case in openfile()

PATCH In review Bill O'Donnell 2 participants 2 messages Jun 29, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_spaceman: close open file for error case in openfile()

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)

---
 spaceman/file.c | 1 +
 1 file changed, 1 insertion(+)
spaceman/file.c +1 -0
index 4ab30900..4c13b4a8 100644
@@ -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));
Signature · 1 line
2.13.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Bill O'Donnell

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)

--D

Quoted 23 lines
---
 spaceman/file.c | 1 +
 1 file changed, 1 insertion(+)
spaceman/file.c +1 -0
index 4ab30900..4c13b4a8 100644
@@ -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));
Signature · 6 lines
2.13.0

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html