[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [PATCH 3/8] mkfs.gfs2: Fix use of uninitialized value in check_dev_content



Spotted by coverity: Using uninitialized value "p[0]" when calling
"close".

Signed-off-by: Andrew Price <anprice redhat com>
---
 gfs2/mkfs/main_mkfs.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 95afe41..3658fd4 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -428,7 +428,7 @@ static void check_dev_content(const char *devname)
 		(char *)"-bs",
 		(char *)devname,
 		NULL };
-	int p[2];
+	int p[2] = {-1, -1};
 	int ret;
 	int pid;
 
@@ -463,7 +463,8 @@ fail:
 				goto fail;
 			printf( _("It appears to contain: %s"), content);
 		}
-		close(p[0]);
+		if (p[0] >= 0)
+			close(p[0]);
 		return;
 	}
 
-- 
1.7.6.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]