From 05f1298b08f2802c164f03dd64cc3e1116eabc45 Mon Sep 17 00:00:00 2001 From: Aditya R Date: Fri, 6 Jan 2023 09:16:11 +0530 Subject: [PATCH] contrib, seccomp-notify-plugin: free args on error to prevent leak Found a small leak while running static check on codebase, free(args) on error to prevent memory leak. Signed-off-by: Aditya R --- contrib/seccomp-notify-plugin-example/full.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/contrib/seccomp-notify-plugin-example/full.c b/contrib/seccomp-notify-plugin-example/full.c index fd31988a..a52cb1d3 100644 --- a/contrib/seccomp-notify-plugin-example/full.c +++ b/contrib/seccomp-notify-plugin-example/full.c @@ -58,24 +58,29 @@ handle_async (struct seccomp_notif_sizes *sizes, struct seccomp_notif *sreq, int args->resp = malloc (sizes->seccomp_notif_resp); if (args->resp == NULL) - return -errno; + goto exit_error; args->id = sreq->id; args->seccomp_fd = seccomp_fd; if (pthread_attr_init (&attr) < 0) - return -errno; + goto exit_error; if (pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) < 0) - return -errno; + goto exit_error; if (pthread_create (&thread, &attr, start_routine, args) < 0) - return -errno; + goto exit_error; if (pthread_attr_destroy (&attr) < 0) - return -errno; + goto exit_error; return 0; + +exit_error: + free (args->resp); + free (args); + return -errno; } int