Message ID | 20250114080410.108067-1-liuye@kylinos.cn (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | selftests/prctl/set-process-name: Fix Resource leak fptr in check_name | expand |
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); }
Exception branch returns without closing fptr. Signed-off-by: liuye <liuye@kylinos.cn> --- tools/testing/selftests/prctl/set-process-name.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)