dmraid/lib/device partition.c

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

 



CVSROOT:	/cvs/dm
Module name:	dmraid
Changes by:	heinzm@xxxxxxxxxxxxxx	2009-12-17 14:29:24

Modified files:
	lib/device     : partition.c 

Log message:
	Avoid fd leak in _remove_subset_partitions (Neil Brown)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/device/partition.c.diff?cvsroot=dm&r1=1.1&r2=1.2

--- dmraid/lib/device/partition.c	2009/12/16 11:39:18	1.1
+++ dmraid/lib/device/partition.c	2009/12/17 14:29:24	1.2
@@ -23,20 +23,27 @@
 
 	list_for_each_entry(rd, &rs->devs, devs) {
 		int fd = open(rd->di->path, O_RDWR);
+
 		if (fd < 0)
 			LOG_ERR(lc, 0, "opening %s: %s\n", rd->di->path,
 				strerror(errno));
 
 		/* There is no way to enumerate partitions */
 		for (part.pno = 1; part.pno <= 256; part.pno++) {
-			if (ioctl(fd, BLKPG, &io) < 0 && errno != ENXIO &&
-					(part.pno < 16 || errno != EINVAL))
+			if (ioctl(fd, BLKPG, &io) < 0 &&
+			    errno != ENXIO &&
+			    (part.pno < 16 || errno != EINVAL)) {
+				close(fd);
 				LOG_ERR(lc, 0,
 					"removing part %d from %s: %s\n",
 					part.pno, rd->di->path,
 					strerror(errno));
+			}
 		}
+
+		close(fd);
 	}
+
 	return 1;
 }
 

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel

[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux