Skip to contentSkip to conversation

selftests: ALSA: Fix fclose on an already fclosed file pointer

PATCH Applied Colin Ian King 3 participants 3 messages Jul 12, 2023 – Jul 13, 2023

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: ALSA: Fix fclose on an already fclosed file pointer

In the case where a sysfs file cannot be opened the error return path fcloses file pointer fpl, however, fpl has already been closed in the previous stanza. Fix the double fclose by removing it.

Fixes 10b98a4db11a ("selftests: ALSA: Add test for the 'pcmtest' driver")
---
 tools/testing/selftests/alsa/test-pcmtest-driver.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
tools/testing/selftests/alsa/test-pcmtest-driver.c +1 -3
index 71931b240a83..357adc722cba 100644
@@ -47,10 +47,8 @@ static int read_patterns(void)
 
 		sprintf(pf, "/sys/kernel/debug/pcmtest/fill_pattern%d", i);
 		fp = fopen(pf, "r");
-		if (!fp) {
-			fclose(fpl);
+		if (!fp)
 			return -1;
-		}
 		fread(patterns[i].buf, 1, patterns[i].len, fp);
 		fclose(fp);
 	}
Signature · 1 line
2.39.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Colin Ian King

In the case where a sysfs file cannot be opened the error return path fcloses file pointer fpl, however, fpl has already been closed in the previous stanza. Fix the double fclose by removing it.

Applied
#2 lore raw
In reply to Colin Ian King
Quoted 7 lines · Colin Ian King

In the case where a sysfs file cannot be opened the error return path fcloses file pointer fpl, however, fpl has already been closed in the previous stanza. Fix the double fclose by removing it.

Fixes 10b98a4db11a ("selftests: ALSA: Add test for the 'pcmtest' driver")

Thanks, applied.

Takashi