From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0D082A0C4D for ; Mon, 16 Aug 2021 14:06:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EE20C4003C; Mon, 16 Aug 2021 14:06:41 +0200 (CEST) Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) by mails.dpdk.org (Postfix) with ESMTP id 42AC54003C for ; Mon, 16 Aug 2021 14:06:41 +0200 (CEST) Received: by mail-oi1-f177.google.com with SMTP id bj40so26352303oib.6 for ; Mon, 16 Aug 2021 05:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iNpLzZQ6lnJhhE3MS0/9XevUi2HYag2X5gAPUzjLoss=; b=bWx+TsyPILWJH8ylBVtbdUIwj/QW7hZ0Asox1OGBb0xYyB70i2doxDpThiKrTgrhIs RqhQi/g/ekkQpO22Iuy84nt6OEiaXkLR8KtFigwUFlgQMWze9IqKqPyGnqhQOkayGXT1 oQfeHNxHwa9iq2Z+MhjVNU9timqosbWUTLPxA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iNpLzZQ6lnJhhE3MS0/9XevUi2HYag2X5gAPUzjLoss=; b=BgoHiGE1fYSHkQaxmKx+X920pKMYWtt0q+whGEmsuUAYNt6iqDuH0k2sy36ANDa69j AxvBypTvrdSnUei/8E0gUX9BfcymRypdA5VAmT8XqPohwpudrAwAFm4cHKswmudT/KZc 5GxzRHtBE/nbqFo79llBOXq+eewou6Lbbe8DM5vHT3aMKDkz/f3NBv93JRq0Stv2OUvw SIlV8rVmWOiqXnDpnmhB7KI//xTDg/VmUIbCuleS5kvY3NEcuKsURzntvCCdjy+Eq3lO HsGmlG6qWmMBLVxfLPzOqAf1565FmLEwWJKZVs8tvSQZvz3KupNdUFHDczX9Cc1a/scd iYSQ== X-Gm-Message-State: AOAM533zCl4PvpLVvicu0AoH4/KhX7t4Nm5yGTxnNOcsh2/nJ7+0KAgF DrXf+h/vHoo75WgGV8u8nMMw9/ft2pL1NqMNjqBTmJvGGD4= X-Google-Smtp-Source: ABdhPJzQXRUpn6GreSwh3oDFduYz5N71rmph+QWz3P+i17zYAhudj8YMWsRbD19cgJxXwBP3l/DNbdvF7VOAOHk/BXM= X-Received: by 2002:a05:6808:10d:: with SMTP id b13mr11498212oie.79.1629115600378; Mon, 16 Aug 2021 05:06:40 -0700 (PDT) MIME-Version: 1.0 References: <20210816120512.12224-1-ohilyard@iol.unh.edu> In-Reply-To: <20210816120512.12224-1-ohilyard@iol.unh.edu> From: Owen Hilyard Date: Mon, 16 Aug 2021 08:06:04 -0400 Message-ID: To: dpdk stable Cc: Christian Ehrhardt , David Marchand Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [dpdk-stable] [PATCH] tests/cmdline: fix memory leaks X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" It looks like an update to my IDE turn back on converting tabs to spaces on save. Sorry about that. On Mon, Aug 16, 2021 at 8:05 AM wrote: > From: Owen Hilyard > > [ upstream commit ca7204b921c2f328ab1222772af40922970e7c4b ] > > Fixes for a few memory leaks in the cmdline_autotest unit test. > > All of the leaks were related to not freeing the commandline struct > after testing had completed. > > Fixes: dbb860e03e ("cmdline: tests") > > Signed-off-by: Owen Hilyard > Reviewed-by: David Marchand > --- > app/test/test_cmdline_lib.c | 47 +++++++++++++++++++++++++++---------- > 1 file changed, 34 insertions(+), 13 deletions(-) > > diff --git a/app/test/test_cmdline_lib.c b/app/test/test_cmdline_lib.c > index a856a9713..7d9009408 100644 > --- a/app/test/test_cmdline_lib.c > +++ b/app/test/test_cmdline_lib.c > @@ -62,10 +62,12 @@ test_cmdline_parse_fns(void) > if (cmdline_complete(&cl, "buffer", &i, NULL, sizeof(dst)) >= 0) > goto error; > > + cmdline_free(&cl); > return 0; > > error: > printf("Error: function accepted null parameter!\n"); > + cmdline_free(&cl); > return -1; > } > > @@ -131,32 +133,43 @@ static int > test_cmdline_socket_fns(void) > { > cmdline_parse_ctx_t ctx; > + struct cmdline* cl; > > - if (cmdline_stdin_new(NULL, "prompt") != NULL) > + cl = cmdline_stdin_new(NULL, "prompt"); > + if (cl != NULL) > goto error; > - if (cmdline_stdin_new(&ctx, NULL) != NULL) > + cl = cmdline_stdin_new(&ctx, NULL); > + if (cl != NULL) > goto error; > - if (cmdline_file_new(NULL, "prompt", "/dev/null") != NULL) > + cl = cmdline_file_new(NULL, "prompt", "/dev/null"); > + if (cl != NULL) > goto error; > - if (cmdline_file_new(&ctx, NULL, "/dev/null") != NULL) > + cl = cmdline_file_new(&ctx, NULL, "/dev/null"); > + if (cl != NULL) > goto error; > - if (cmdline_file_new(&ctx, "prompt", NULL) != NULL) > + cl = cmdline_file_new(&ctx, "prompt", NULL); > + if (cl != NULL) > goto error; > - if (cmdline_file_new(&ctx, "prompt", "-/invalid/~/path") != NULL) { > + cl = cmdline_file_new(&ctx, "prompt", "-/invalid/~/path"); > + if (cl != NULL) { > printf("Error: succeeded in opening invalid file for > reading!"); > + cmdline_free(cl); > return -1; > } > - if (cmdline_file_new(&ctx, "prompt", "/dev/null") == NULL) { > + cl = cmdline_file_new(&ctx, "prompt", "/dev/null"); > + if (cl == NULL) { > printf("Error: failed to open /dev/null for reading!"); > + cmdline_free(cl); > return -1; > } > > /* void functions */ > cmdline_stdin_exit(NULL); > - > + cmdline_free(cl); > return 0; > error: > printf("Error: function accepted null parameter!\n"); > + cmdline_free(cl); > return -1; > } > > @@ -164,16 +177,20 @@ static int > test_cmdline_fns(void) > { > cmdline_parse_ctx_t ctx; > - struct cmdline cl, *tmp; > + struct cmdline cl, *tmp, *tmp2; > > memset(&ctx, 0, sizeof(ctx)); > tmp = cmdline_new(&ctx, "test", -1, -1); > - if (tmp == NULL) > + if (tmp == NULL) { > + tmp2 = NULL; > goto error; > + } > > - if (cmdline_new(NULL, "prompt", 0, 0) != NULL) > + tmp2 = cmdline_new(NULL, "prompt", 0, 0); > + if (tmp2 != NULL) > goto error; > - if (cmdline_new(&ctx, NULL, 0, 0) != NULL) > + tmp2 = cmdline_new(&ctx, NULL, 0, 0); > + if (tmp2 != NULL) > goto error; > if (cmdline_in(NULL, "buffer", CMDLINE_TEST_BUFSIZE) >= 0) > goto error; > @@ -202,14 +219,18 @@ test_cmdline_fns(void) > if (memcmp(&cl, tmp, sizeof(cl))) goto mismatch; > > cmdline_free(tmp); > - > + cmdline_free(tmp2); > return 0; > > error: > printf("Error: function accepted null parameter!\n"); > + cmdline_free(tmp); > + cmdline_free(tmp2); > return -1; > mismatch: > printf("Error: data changed!\n"); > + cmdline_free(tmp); > + cmdline_free(tmp2); > return -1; > } > > -- > 2.30.2 > >