Skip to content

Commit

Permalink
selftests: ALSA: Fix fclose on an already fclosed file pointer
Browse files Browse the repository at this point in the history
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: 10b98a4 ("selftests: ALSA: Add test for the 'pcmtest' driver")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230712140122.457206-1-colin.i.king@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Colin Ian King authored and Takashi Iwai committed Jul 13, 2023
1 parent 35bc3ef commit 645e583
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions tools/testing/selftests/alsa/test-pcmtest-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 645e583

Please sign in to comment.