Justin Vreeland b079dd
diff -up hdparm-9.60/sysfs.c.bak hdparm-9.60/sysfs.c
Justin Vreeland b079dd
--- hdparm-9.60/sysfs.c.bak	2021-04-15 15:48:56.806354847 +0200
Justin Vreeland b079dd
+++ hdparm-9.60/sysfs.c	2021-04-16 14:44:42.520395436 +0200
Justin Vreeland b079dd
@@ -61,7 +61,8 @@ static int sysfs_write_attr (char *path,
Justin Vreeland b079dd
 		if (count < 0)
Justin Vreeland b079dd
 			err = errno;
Justin Vreeland b079dd
 	}
Justin Vreeland b079dd
-	fclose(fp);
Justin Vreeland b079dd
+	if (fp)
Justin Vreeland b079dd
+		fclose(fp);
Justin Vreeland b079dd
 	if (err && verbose) perror(path);
Justin Vreeland b079dd
 	*pathtail = '\0';
Justin Vreeland b079dd
 	return err;