[stgt] [PATCH] Close files if there is an error while reading/writing to them

Malahal Naineni malahal at us.ibm.com
Fri Feb 12 06:13:12 CET 2010


diff -r 0497a5145753 -r 07e009f3609d usr/tgtd.c
--- a/usr/tgtd.c	Thu Feb 11 20:51:11 2010 -0800
+++ b/usr/tgtd.c	Thu Feb 11 21:06:30 2010 -0800
@@ -91,6 +91,7 @@ static int oom_adjust(void)
 	err = write(fd, "-17\n", 4);
 	if (err < 0) {
 		fprintf(stderr, "can't adjust oom-killer's pardon %s, %m\n", path);
+		close(fd);
 		return errno;
 	}
 	close(fd);
@@ -113,6 +114,7 @@ static int nr_file_adjust(void)
 	ret = read(fd, buf, sizeof(buf));
 	if (ret < 0) {
 		fprintf(stderr, "can't read %s, %m\n", path);
+		close(fd);
 		return errno;
 	}
 	close(fd);
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list