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 1743CA0547 for ; Wed, 11 Aug 2021 13:18:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D321840042; Wed, 11 Aug 2021 13:18:06 +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 E7C8F40042 for ; Wed, 11 Aug 2021 13:18:05 +0200 (CEST) Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (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 AA7FF3F0B9 for ; Wed, 11 Aug 2021 11:18:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1628680685; bh=FGt03+JDctXnQv0Tw00a/jgGcHPBua5iMPIKrobOpeM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=MTGYkKoNVe5GxiruOG18Y3DIH8r8oWzwJLwByTpXlxbNGKMEScAti+a07uqAeZrHI jgMFOsC1Na6sEHJwOmmHiPT2muaKBJmFs9HtyuM7aXwFF1m03p1tiOfq34lpi8XX1E 5/42eaKcUtnEKjrJvsoaL25788NsBe4Zd38LFKX+1k1IjfSOnKifT6VnzurSzwN4AH PlW+WMWJ999E29+Qwg3Gf857ewqv2DI+PrN7gZymdyS3DVkXDll0qWN4bPdiM/Vrf4 QR2i9QkCN4jcCYMz4WTV+muGozN6/5WsrP7CIBujXqLj6oPeXmVYJseV11hJEwkeoJ YONoNRHF7B8Kw== Received: by mail-qv1-f71.google.com with SMTP id a3-20020a0cb3430000b02903432d100232so1063196qvf.16 for ; Wed, 11 Aug 2021 04:18:05 -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:content-transfer-encoding; bh=FGt03+JDctXnQv0Tw00a/jgGcHPBua5iMPIKrobOpeM=; b=SJT8Qc9DHvsrKBzKQ+NJaQxN4XjkJgfmxuDLU8A3KPl4ZixbvUQtmqfw6LtpJmwp+w 9sML7D6+4TQ0PTkI3CFrjX1xqrLN6JU2qc8MEjxa1xyJhQR75GxF5EtVtdf/dotnQfWU 0/+YjCdNKsYjz7xvaPgg4OM39AVrFzQ+y3Q7YA+b5/USCg/RxnrMU2EF+LY6f+bCxhAc 8iahpB6XfgvI3FMpvrku6MIkrY9muFDRzkn1TLkGu9tNQKBkz4KGhF/XAHQfnGP6OwoU GpHxuHTvfkWJjIWQVCVRWDQ4kZjaUtCl7yk2gHh8ZsUkYNvbQJvfPAzjSE7fL/pCW9aD 7/RA== X-Gm-Message-State: AOAM531h4izyM6jAvniuKaGTU4lmHa/EPmaWVDTBwmX4y9UTtkJNuTxt mZwHEZOxdE2rNO2EShon7SNKac2Ct94YdSC2MW7ZK4fPNKDdqHdmp26BYe0soI1AiMGfPwnFTp0 PxPTjnFos66B5AdxOQ/1YKGti4NwScThtjAfslCRW X-Received: by 2002:a05:622a:652:: with SMTP id a18mr11072752qtb.112.1628680684699; Wed, 11 Aug 2021 04:18:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVpY+WxrQtTX3/2RZnfaLopi7zwMZjfZtOvEPKfCKjMj7404dKcXDcqyg5q5JW2A0kd4szbdEU6UJNuewm4bA= X-Received: by 2002:a05:622a:652:: with SMTP id a18mr11072729qtb.112.1628680684420; Wed, 11 Aug 2021 04:18:04 -0700 (PDT) MIME-Version: 1.0 References: <20210810173950.98785-1-ohilyard@iol.unh.edu> In-Reply-To: From: Christian Ehrhardt Date: Wed, 11 Aug 2021 13:17:38 +0200 Message-ID: To: Owen Hilyard Cc: dpdk stable , David Marchand Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Wed, Aug 11, 2021 at 11:45 AM Christian Ehrhardt wrote: > > On Wed, Aug 11, 2021 at 8:43 AM Christian Ehrhardt > wrote: > > > > 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 > > Actually this causes > ../app/test/test_cmdline_lib.c: In function =E2=80=98test_cmdline_socket_= fns=E2=80=99: > ../app/test/test_cmdline_lib.c:138:8: warning: assignment to =E2=80=98str= uct > cmdline *=E2=80=99 from =E2=80=98int=E2=80=99 makes pointer from integer = without a cast > [-Wint-conversion] > 138 | cl =3D cmdline_stdin_new(NULL, "prompt") !=3D NULL); > | ^ > ../app/test/test_cmdline_lib.c:138:51: error: expected =E2=80=98;=E2=80= =99 before =E2=80=98)=E2=80=99 token > 138 | cl =3D cmdline_stdin_new(NULL, "prompt") !=3D NULL); > | ^ > ../app/test/test_cmdline_lib.c:138:51: error: expected statement > before =E2=80=98)=E2=80=99 token > > It has various issues, see below: > > > > 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)) >= =3D 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") !=3D NULL) > > > + cl =3D cmdline_stdin_new(NULL, "prompt") !=3D NULL); > > Changed to an assignment but kept the comparison of the if =3D> failing. > > > > + if (cl !=3D NULL) > > > goto error; > > > - if (cmdline_stdin_new(&ctx, NULL) !=3D NULL) > > > + cl =3D cmdline_stdin_new(&ctx, NULL); > > > + if (cl !=3D NULL) > > ^^ all those add whitespace damage replacing a tab with spaces > > > I have fixed all those into > https://github.com/cpaelzer/dpdk-stable-queue/commit/4c36f7b56fb4bc12b9d1= 9ca21db4207298afead0 Even with that if fails like [ 1044s] ../app/test/test_cmdline_lib.c: In function =E2=80=98test_cmdline_= fns=E2=80=99: [ 1044s] ../app/test/test_cmdline_lib.c:227:2: error: =E2=80=98tmp2=E2=80= =99 may be used uninitialized in this function [-Werror=3Dmaybe-uninitialized] [ 1044s] 227 | cmdline_free(tmp2); [ 1044s] | ^~~~~~~~~~~~~~~~~~ I'll de-queue it from 19.11 for now and would appreciate it if you could check it more thoroughly than I did. > But please give all of it a second look > > > > goto error; > > > - if (cmdline_file_new(NULL, "prompt", "/dev/null") !=3D NULL) > > > + cl =3D cmdline_file_new(NULL, "prompt", "/dev/null"); > > > + if (cl !=3D NULL) > > > goto error; > > > - if (cmdline_file_new(&ctx, NULL, "/dev/null") !=3D NULL) > > > + cl =3D cmdline_file_new(&ctx, NULL, "/dev/null"); > > > + if (cl !=3D NULL) > > > goto error; > > > - if (cmdline_file_new(&ctx, "prompt", NULL) !=3D NULL) > > > + cl =3D cmdline_file_new(&ctx, "prompt", NULL); > > > + if (cl !=3D NULL) > > > goto error; > > > - if (cmdline_file_new(&ctx, "prompt", "-/invalid/~/path") !=3D= NULL) { > > > + cl =3D cmdline_file_new(&ctx, "prompt", "-/invalid/~/path"); > > > + if (cl !=3D NULL) { > > > printf("Error: succeeded in opening invalid file for = reading!"); > > > + cmdline_free(cl); > > > return -1; > > > } > > > - if (cmdline_file_new(&ctx, "prompt", "/dev/null") =3D=3D NULL= ) { > > > + cl =3D cmdline_file_new(&ctx, "prompt", "/dev/null"); > > > + if (cl =3D=3D 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 =3D cmdline_new(&ctx, "test", -1, -1); > > > if (tmp =3D=3D NULL) > > > goto error; > > > > > > - if (cmdline_new(NULL, "prompt", 0, 0) !=3D NULL) > > > + tmp2 =3D cmdline_new(NULL, "prompt", 0, 0); > > > + if (tmp2 !=3D NULL) > > > goto error; > > > - if (cmdline_new(&ctx, NULL, 0, 0) !=3D NULL) > > > + tmp2 =3D cmdline_new(&ctx, NULL, 0, 0); > > > + if (tmp2 !=3D NULL) > > > goto error; > > > if (cmdline_in(NULL, "buffer", CMDLINE_TEST_BUFSIZE) >=3D 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 > > > > -- > Christian Ehrhardt > Staff Engineer, Ubuntu Server > Canonical Ltd --=20 Christian Ehrhardt Staff Engineer, Ubuntu Server Canonical Ltd