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

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

 



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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux