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 65FE4A034F for ; Wed, 11 Aug 2021 08:43:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C32640040; Wed, 11 Aug 2021 08:43:55 +0200 (CEST) Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) by mails.dpdk.org (Postfix) with ESMTP id 2CD2440040 for ; Wed, 11 Aug 2021 08:43:54 +0200 (CEST) Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPS id D408E3F102 for ; Wed, 11 Aug 2021 06:43:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1628664233; bh=Cyzda731Y9V/7nZjgNGtqGR5V8I/M+flFkkiQFzjzXI=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=DwVyloGznDvb1Z6i8iOH0OOFclZQUt3aXp2KKajsTMPJrKEzAfTDhrLi/uhpwGgc7 IbKzNZiJ/VsL/YB4uul9DDeebkx7v3hFjsJMHEYh94efLB688RpxGNidIwhl0QuvjR kUgddY7d2gxYhbU3Q8Pj7E6zHMKSw8k7keKTpbGViAsZGFC1n5ft467mPV6aKPklik O0+I2ZOlXPNvl0rcC/W6YAfIt2ssKc52HhdVy4xe5HUJLnIfh0iN65pz+jhK0ujEed UTYlOV0pH5fsXeWCcF6ng6s9CKoBOVUlCTeFAT3BjbOKEZkVLibNGaP9S6v9PXqDK7 gjKiNhq9zYFFQ== Received: by mail-qv1-f69.google.com with SMTP id k7-20020ad453c70000b02902f36ca6afdcso726330qvv.7 for ; Tue, 10 Aug 2021 23:43:53 -0700 (PDT) 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=Cyzda731Y9V/7nZjgNGtqGR5V8I/M+flFkkiQFzjzXI=; b=Ial3wr/rC7XP2+teb/4RTWlPQbwZU6cPYo7ToUIXR8/A5IqQu2re03pxUu3IWhEl2Y SfNOoZGxCwIeeLd1BvUz7TmLKfgP23alJc+6ZkSznP/JQXcysYxR2plemPOT7Wye+Cv5 lqgJfXrKxaVAAbcyUmdhAzsCgXKm5jR43SaNjQ1Iv35A/O+lrSW6BCJZJXO3EefgYfeO VwJRPZY1gkIwTM+aU1sJkjHzPqQbi11mZpNw5RBVfMR/95kR0vwjJ56Y9TO1/UmfH8es AWyEj3AUJlkimWZgwxTaS5XGqc98AD6avpnBchAsfKP0J8ilR0HWxdT02lWoekHYuw85 HmtA== X-Gm-Message-State: AOAM531HpJJkNQKSL3eJxCLRJZyuezWUDs27MLyMeB3Xo+4ibTu8Skx5 Y7UPGE5oep/juqIFDizWTAWImtSbuJS5mEfFZKtM1iBMJ4HvI5IUFcOkpLXJzSewbnayoONvVdx KVfA0bjaC0b7u4UfpxofjxgVISJbzqZu7pKRXpery X-Received: by 2002:a0c:be85:: with SMTP id n5mr21449336qvi.59.1628664232818; Tue, 10 Aug 2021 23:43:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQqtsea7lu7uYGZHIskRM0s0cBHbitgTy0gk7EZNzaf1nNUJW/kkfe2isRqvgwQLNaID63JEYPo7aqdvlEfQU= X-Received: by 2002:a0c:be85:: with SMTP id n5mr21449322qvi.59.1628664232652; Tue, 10 Aug 2021 23:43:52 -0700 (PDT) MIME-Version: 1.0 References: <20210810173950.98785-1-ohilyard@iol.unh.edu> In-Reply-To: <20210810173950.98785-1-ohilyard@iol.unh.edu> From: Christian Ehrhardt Date: Wed, 11 Aug 2021 08:43:27 +0200 Message-ID: To: Owen Hilyard Cc: dpdk stable , David Marchand Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-stable] [PATCH 19.11] 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" On Tue, Aug 10, 2021 at 7:40 PM wrote: > > From: Owen Hilyard > > [ upstream commit ca7204b921c2f328ab1222772af40922970e7c4b ] > > Fixes for a few memory leaks in the cmdline_autotest unit test. Thank you for the backport - applied to the preliminary 19.11 branch for 19.11.10 > 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 | 43 ++++++++++++++++++++++++++----------- > 1 file changed, 31 insertions(+), 12 deletions(-) > > diff --git a/app/test/test_cmdline_lib.c b/app/test/test_cmdline_lib.c > index a856a9713..c7ada9ddd 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") != NULL); > + 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,18 @@ 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) > 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 +217,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 > -- Christian Ehrhardt Staff Engineer, Ubuntu Server Canonical Ltd