]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/posix-pipe: Fix ref leak on pipe creation
authorAndrei Tatar <andrei@unikraft.io>
Tue, 19 Nov 2024 12:55:28 +0000 (13:55 +0100)
committerUnikraft Bot <monkey@unikraft.io>
Mon, 9 Dec 2024 18:16:45 +0000 (18:16 +0000)
Previously uk_sys_pipe would return pipe files with one too many
references counted, leading to pipes never closing and leaking memory.
This change corrects this oversight by releasing the raw pipe files
after they have been entered into the fdtab.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1539

lib/posix-pipe/pipe.c

index beb07acd6bbfd7307e93dbb332769cbbc2ef596b..bb45167f10f9292763519be0bbbe94743df4d6a8 100644 (file)
@@ -433,6 +433,8 @@ int uk_sys_pipe(int pipefd[2], int flags)
        if (unlikely(r < 0))
                goto err_close;
 
+       uk_file_release(pipes[0]);
+       uk_file_release(pipes[1]);
        pipefd[0] = rpipe;
        pipefd[1] = r;
        return  0;