[dm-devel] [PATCH 26/39] kpartx: fixup filedescriptor leak in set_loop()

Hannes Reinecke hare at suse.de
Thu Jun 16 09:47:32 UTC 2016


Upon error 'ffd' was never closed.
Found by coverity.

Signed-off-by: Hannes Reinecke <hare at suse.com>
---
 kpartx/lopart.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kpartx/lopart.c b/kpartx/lopart.c
index e7f6090..5495e27 100644
--- a/kpartx/lopart.c
+++ b/kpartx/lopart.c
@@ -252,6 +252,7 @@ set_loop (const char *device, const char *file, int offset, int *loopro)
 	}
 
 	if ((fd = open (device, mode)) < 0) {
+		close(ffd);
 		perror (device);
 		return 1;
 	}
-- 
2.6.6




More information about the dm-devel mailing list