Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5023445yba; Wed, 8 May 2019 06:47:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjx5lxRF7gMMEvqolB6523zjnDzyBqY5MxP+c5ov6JkYnsIk5MRH87LqAmigj3XnMdBzEX X-Received: by 2002:a63:d615:: with SMTP id q21mr27441639pgg.401.1557323265200; Wed, 08 May 2019 06:47:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557323265; cv=none; d=google.com; s=arc-20160816; b=FDZHNAvWU8XoTimIntD+VYpjoLTNDs3Tvaem0DAANWMXLzUuxBkcnYJM2xnupTU88y V9R3fmechqgqBAwl4VeTG4YBwm68qWVozJy9KrjoS3Ni2KPbyIwOZFdh0C2Ff1Lhyg7k tgNwry2dVW26+ezOCKWYaAuaxfsVIKzbWfJD+DlJk5tZUKnD3X7P96w3dvyLnMATw+eO FiaHRi/tboYwqsmk3722NduxaBjJllFQGHAdUkaUF9SzIalb1mQsYVbj4iPcnsPxfXud b2ISP/AF9kU4m26FY+ejZIOQwTxkWDxG0bJ2b/4yeuLI+GpfRbaYETQqjwCk3DhUTDpk cvPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from; bh=Rb2IXFem+isjdbYozrSz/ACJkLCIYV7taXre4qj7pvM=; b=p+nOz7xayKUUj7TkZltGwQWKg8hyhCmHtrb1jljQmxJ3S2FYROCGlu6Q/A0G53SYJt b5e3DfiCEFGYm9QtF3KwzYSWhv8LphJXYuiZQ1dGSnUeiSvV+WpdsI35GPMk3b3WyDWG zARP61d7fCah35okPccvwXuFn6MD48YYGgheRogIHmpNQy/xQtzqm7d1YoZbSOjP27W0 a/u3lBEEoHxHUKaOgGsDb57R7KSrdGWWa9a2XP+UXG3eX2ZEE9m2RJLAa7yADpTXyIrb ouUaSnmhoIBTC1nQkyVmnUBk9xet6oyPlYLLiv8UrPJCG6VYlnTBZv9qItGjOBdlFfYS WRxA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12si24596340pgn.431.2019.05.08.06.47.29; Wed, 08 May 2019 06:47:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727071AbfEHNfp (ORCPT + 99 others); Wed, 8 May 2019 09:35:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39054 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727256AbfEHNfp (ORCPT ); Wed, 8 May 2019 09:35:45 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 15461821EF for ; Wed, 8 May 2019 13:35:45 +0000 (UTC) Received: from madhat.boston.devel.redhat.com (ovpn-116-59.phx2.redhat.com [10.3.116.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4DE15C269 for ; Wed, 8 May 2019 13:35:44 +0000 (UTC) From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH 11/19] Removed resource leaks from systemd/rpc-pipefs-generator.c Date: Wed, 8 May 2019 09:35:28 -0400 Message-Id: <20190508133536.6077-12-steved@redhat.com> In-Reply-To: <20190508133536.6077-1-steved@redhat.com> References: <20190508133536.6077-1-steved@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 08 May 2019 13:35:45 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org systemd/rpc-pipefs-generator.c:73: leaked_storage: Variable "pipefs_unit" going out of scope leaks the storage it points to systemd/rpc-pipefs-generator.c:77: leaked_storage: Variable "pipefs_unit" going out of scope leaks the storage it points to. systemd/rpc-pipefs-generator.c:85: leaked_storage: Variable "pipefs_unit" going out of scope leaks the storage it points to. systemd/rpc-pipefs-generator.c:94: leaked_storage: Variable "pipefs_unit" going out of scope leaks the storage it points to. Signed-off-by: Steve Dickson --- systemd/rpc-pipefs-generator.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/systemd/rpc-pipefs-generator.c b/systemd/rpc-pipefs-generator.c index 0b5da11..8e218aa 100644 --- a/systemd/rpc-pipefs-generator.c +++ b/systemd/rpc-pipefs-generator.c @@ -69,12 +69,16 @@ int generate_target(char *pipefs_path, const char *dirname) return 1; ret = generate_mount_unit(pipefs_path, pipefs_unit, dirname); - if (ret) + if (ret) { + free(pipefs_unit); return ret; + } path = malloc(strlen(dirname) + 1 + sizeof(filebase)); - if (!path) + if (!path) { + free(pipefs_unit); return 2; + } sprintf(path, "%s", dirname); mkdir(path, 0755); strcat(path, filebase); @@ -82,6 +86,7 @@ int generate_target(char *pipefs_path, const char *dirname) if (!f) { free(path); + free(pipefs_unit); return 1; } @@ -90,6 +95,7 @@ int generate_target(char *pipefs_path, const char *dirname) fprintf(f, "After=%s\n", pipefs_unit); fclose(f); free(path); + free(pipefs_unit); return 0; } -- 2.20.1