diff mbox series

[next] selftests: ALSA: Fix fclose on an already fclosed file pointer

Message ID 20230712140122.457206-1-colin.i.king@gmail.com (mailing list archive)
State Accepted
Commit 645e583d2689a1dd2163da28a7789b4d9febf316
Headers show
Series [next] selftests: ALSA: Fix fclose on an already fclosed file pointer | expand

Commit Message

Colin Ian King July 12, 2023, 2:01 p.m. UTC
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")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 tools/testing/selftests/alsa/test-pcmtest-driver.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Mark Brown July 12, 2023, 3:53 p.m. UTC | #1
On Wed, Jul 12, 2023 at 03:01:22PM +0100, Colin Ian King wrote:
> 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.

Reviewed-by: Mark Brown <broonie@kernel.org>
Takashi Iwai July 13, 2023, 6:08 a.m. UTC | #2
On Wed, 12 Jul 2023 16:01:22 +0200,
Colin Ian King wrote:
> 
> 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")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>

Thanks, applied.


Takashi
diff mbox series

Patch

diff --git a/tools/testing/selftests/alsa/test-pcmtest-driver.c b/tools/testing/selftests/alsa/test-pcmtest-driver.c
index 71931b240a83..357adc722cba 100644
--- a/tools/testing/selftests/alsa/test-pcmtest-driver.c
+++ b/tools/testing/selftests/alsa/test-pcmtest-driver.c
@@ -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);
 	}