diff mbox

[dmraid,2/4] Avoid fd leak in remove_device_partitions.

Message ID 20091217054520.996066834@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

NeilBrown Dec. 17, 2009, 5:44 a.m. UTC
None
diff mbox

Patch

--- dmraid-16.orig/lib/device/partition.c
+++ dmraid-16/lib/device/partition.c
@@ -30,12 +30,15 @@  _remove_subset_partitions(struct lib_con
 		/* 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))
+					(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;
 }