Blame SOURCES/hdparm-9.54-resourceleak-fixes.patch

e5fd4a
diff -urN hdparm-9.54/fibmap.c hdparm-9.54_patched/fibmap.c
e5fd4a
--- hdparm-9.54/fibmap.c	2016-10-13 01:50:52.000000000 +0200
e5fd4a
+++ hdparm-9.54_patched/fibmap.c	2018-10-04 12:17:39.630627349 +0200
e5fd4a
@@ -232,6 +232,7 @@
e5fd4a
 	if (fstat(fd, &st) == -1) {
e5fd4a
 		err = errno;
e5fd4a
 		perror(file_name);
e5fd4a
+		close(fd);
e5fd4a
 		return err;
e5fd4a
 	}
e5fd4a
 	if (!S_ISREG(st.st_mode)) {
e5fd4a
diff -urN hdparm-9.54/fwdownload.c hdparm-9.54_patched/fwdownload.c
e5fd4a
--- hdparm-9.54/fwdownload.c	2017-12-06 13:41:40.000000000 +0100
e5fd4a
+++ hdparm-9.54_patched/fwdownload.c	2018-10-04 12:19:23.819336125 +0200
e5fd4a
@@ -95,12 +95,19 @@
e5fd4a
 	int xfer_min = 1, xfer_max = 0xffff, xfer_size;
e5fd4a
 	ssize_t offset;
e5fd4a
 
e5fd4a
-	if ((fwfd = open(fwpath, O_RDONLY)) == -1 || fstat(fwfd, &st) == -1) {
e5fd4a
+	if ((fwfd = open(fwpath, O_RDONLY)) == -1) {
e5fd4a
 		err = errno;
e5fd4a
 		perror(fwpath);
e5fd4a
 		return err;
e5fd4a
 	}
e5fd4a
 
e5fd4a
+	if (fstat(fwfd, &st) == -1) {
e5fd4a
+		err = errno;
e5fd4a
+		perror(fwpath);
e5fd4a
+		close(fwfd);
e5fd4a
+		return err;
e5fd4a
+	}
e5fd4a
+
e5fd4a
 	if (!S_ISREG(st.st_mode)) {
e5fd4a
 		fprintf(stderr, "%s: not a regular file\n", fwpath);
e5fd4a
 		err = EINVAL;
e5fd4a
diff -urN hdparm-9.54/hdparm.c hdparm-9.54_patched/hdparm.c
e5fd4a
--- hdparm-9.54/hdparm.c	2018-02-03 19:10:40.000000000 +0100
e5fd4a
+++ hdparm-9.54_patched/hdparm.c	2018-10-04 13:25:58.924126976 +0200
e5fd4a
@@ -590,6 +590,9 @@
e5fd4a
 	printf("\n");
e5fd4a
 	printf("\n * signifies the current active mode\n");
e5fd4a
 	printf("\n");
e5fd4a
+	free(fwrev);
e5fd4a
+	free(model);
e5fd4a
+	free(serno);
e5fd4a
 }
e5fd4a
 
e5fd4a
 static const char *busstate_str (unsigned int value)
e5fd4a
@@ -1174,8 +1177,10 @@
e5fd4a
 	if (!shortened)
e5fd4a
 		fdevname = strdup("the full disk");
e5fd4a
 
e5fd4a
-	if (start_lba == 0ULL)
e5fd4a
+	if (start_lba == 0ULL) {
e5fd4a
+		free(fdevname);
e5fd4a
 		return 0;
e5fd4a
+	}
e5fd4a
 	if (start_lba == START_LBA_UNKNOWN || fd_is_raid(fd)) {
e5fd4a
 		fprintf(stderr, "%s is a RAID device: please specify an absolute LBA of a raw member device instead (raid1 only)\n", devname);
e5fd4a
 	} else if (msg) {
e5fd4a
@@ -1187,6 +1192,7 @@
e5fd4a
 		fprintf(stderr, "The absolute LBA of sector %llu from %s should be %llu\n", lba, devname, start_lba + lba);
e5fd4a
 	}
e5fd4a
 	fprintf(stderr, "Aborting.\n");
e5fd4a
+	free(fdevname);
e5fd4a
 	exit(EINVAL);
e5fd4a
 }
e5fd4a
 
e5fd4a
diff -urN hdparm-9.54/sysfs.c hdparm-9.54_patched/sysfs.c
e5fd4a
--- hdparm-9.54/sysfs.c	2018-10-04 12:14:29.900157666 +0200
e5fd4a
+++ hdparm-9.54_patched/sysfs.c	2018-10-04 14:13:07.056659514 +0200
e5fd4a
@@ -60,8 +63,8 @@
e5fd4a
 		}
e5fd4a
 		if (count < 0)
e5fd4a
 			err = errno;
e5fd4a
-		fclose(fp);
e5fd4a
 	}
e5fd4a
+	fclose(fp);
e5fd4a
 	if (err && verbose) perror(path);
e5fd4a
 	*pathtail = '\0';
e5fd4a
 	return err;