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