From patchwork Wed Feb 1 10:57:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhi Li X-Patchwork-Id: 13124142 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 778FDC636D3 for ; Wed, 1 Feb 2023 10:58:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231799AbjBAK6P (ORCPT ); Wed, 1 Feb 2023 05:58:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229582AbjBAK6P (ORCPT ); Wed, 1 Feb 2023 05:58:15 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67B65CDD7 for ; Wed, 1 Feb 2023 02:57:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675249050; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=J+C9U/BbzHtjpC4uZcIYnW7RXFdIpm7vvdmLAYNajOs=; b=PGD7ljQJiH+Uz84RYbVhcuq9SCD8MiIb3b8RixuwPiNYkJq9+IVoUv+xCULR04TPzOtOOh XE4dJC25ou4g/bXN127E2bdlpTCMBhn/4RzOSdaFb/E1RZSgijmbbWzZlz81m7Q5KAqU4a 3VuYU2Dlwxfl1kmGqlBJ47mWfKsuqK4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-280-36wqC79rNUWtUlgHVGFZTw-1; Wed, 01 Feb 2023 05:57:29 -0500 X-MC-Unique: 36wqC79rNUWtUlgHVGFZTw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 397448027ED for ; Wed, 1 Feb 2023 10:57:29 +0000 (UTC) Received: from localhost (unknown [10.66.60.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97B93140EBF4; Wed, 1 Feb 2023 10:57:28 +0000 (UTC) From: Zhi Li To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, Zhi Li Subject: [PATCH] [nfs/nfs-utils/libtirpc] getnetconfig.c: free linep to avoid memory leakage Date: Wed, 1 Feb 2023 18:57:25 +0800 Message-Id: <20230201105725.3500063-1-yieli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Zhi Li --- src/getnetconfig.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/getnetconfig.c b/src/getnetconfig.c index 9acd8c7..afbf8b5 100644 --- a/src/getnetconfig.c +++ b/src/getnetconfig.c @@ -507,9 +507,7 @@ getnetconfigent(netid) break; } } while (stringp != NULL); - if (ncp == NULL) { - free(linep); - } + free(linep); fclose(file); return(ncp); }