Exception branch returns without closing fptr. Signed-off-by: liuye <liuye@xxxxxxxxxx> --- tools/testing/selftests/prctl/set-process-name.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/prctl/set-process-name.c b/tools/testing/selftests/prctl/set-process-name.c index 562f707ba771..625218fa0379 100644 --- a/tools/testing/selftests/prctl/set-process-name.c +++ b/tools/testing/selftests/prctl/set-process-name.c @@ -66,14 +66,18 @@ int check_name(void) return -EIO; fscanf(fptr, "%s", output); - if (ferror(fptr)) + if (ferror(fptr)) { + fclose(fptr); return -EIO; + } int res = prctl(PR_GET_NAME, name, NULL, NULL, NULL); - if (res < 0) + if (res < 0) { + fclose(fptr); return -errno; - + } + fclose(fptr); return !strcmp(output, name); } -- 2.25.1