Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp4638842ioo; Tue, 31 May 2022 08:28:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTNBhCLdClL66DiNSlzgNHif60CvPcKqsrHHbUyKOggntIG+jGVY6fWdshIyICvgBNE5rm X-Received: by 2002:aa7:84d6:0:b0:518:8b7d:bdad with SMTP id x22-20020aa784d6000000b005188b7dbdadmr47935335pfn.59.1654010903432; Tue, 31 May 2022 08:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654010903; cv=none; d=google.com; s=arc-20160816; b=aVpsUhwGp/gaxG7rjRv/zPzQpvn/0VYyhXDYE7LatOpoSedyhdfPw7WZw6nCo9UJfk 39QA+RIvMd9C97yxJt1pHPOlHNz3CwjORpYDhDMIszF4Xot6nhIoejv90dVTMuCNDlg4 6cIz8pLIQ9kX2054eLqYuPlvMNItJ128NLg7kzZ+og1+VafthXbdQiyLBqYlK+DVVA0E BiMEecpEVkFFtD6Zs0aJgKYSHKLdsyUubVTdnOn6vBnqwAKr2/a1YnFbLQejEtQquD0A LL1gwi9WZo8EUbFR/sly0wCJ/vo1JQQ1UY7iZYyAKJaoVeZtDmhMbsvYt5FhMpkV4BwB xpSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ZqmAfcqTl5mRLmng70zlt5ZsObEYM7YOWcflW4WjmtU=; b=bCJkJfXAqNRs9Jse/Br47wTSbXESG1PiJvUzU+GWZx7ShzkfTRCEupcpciXX650kcp OerK7sQGruiv+RPAh34NP29srFBDB8LgOmMUm5s89pLQbeuLJQDYXqP3bILxazVuB+qw ixlw8g5pCnW857mv1TeMdHUqDzyGxicysNuArVrb5yyXvO/5ZeC7jGEMkXr9KYOwFDQD IckQ3+BuyrF6Ya0eJxYzY3NqUo6GKq2SyPdi5PGi5U3lsrru5GDQJB56LV/j3Pkc2xWF joH4flNoAmpxm1VPVZ2HZp0nzpFZ7JDin/Fi/f8p3XbCIF3pXS8fjjyRgNSlknjjMas1 J+hg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oa3-20020a17090b1bc300b001e0c81a5ef5si3437883pjb.87.2022.05.31.08.27.51; Tue, 31 May 2022 08:28:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244583AbiEaHmQ (ORCPT + 99 others); Tue, 31 May 2022 03:42:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244599AbiEaHmG (ORCPT ); Tue, 31 May 2022 03:42:06 -0400 Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [205.139.111.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3731914017 for ; Tue, 31 May 2022 00:41:52 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-270-b_X-esbRNaGrXcNdhl4XRQ-1; Tue, 31 May 2022 03:41:50 -0400 X-MC-Unique: b_X-esbRNaGrXcNdhl4XRQ-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 DF4DA29AB3F9; Tue, 31 May 2022 07:41:49 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.64.242.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C1EF1410F36; Tue, 31 May 2022 07:41:47 +0000 (UTC) From: Gopal Tiwari To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, gtiwari@redhat.com Subject: [Bluez V2 08/13] Fixing resource leak in mesh/mesh-db.c Date: Tue, 31 May 2022 13:11:12 +0530 Message-Id: <20220531074117.610321-9-gopalkrishna.tiwari@gmail.com> In-Reply-To: <20220531074117.610321-1-gopalkrishna.tiwari@gmail.com> References: <20220531074117.610321-1-gopalkrishna.tiwari@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Gopal Tiwari While performing static tool analysis using coverity found following reports for resouse leak bluez-5.64/tools/mesh/mesh-db.c:2388: leaked_handle: Handle variable "fd" going out of scope leaks the handle. bluez-5.64/tools/mesh/mesh-db.c:2388: leaked_storage: Variable "str" going out of scope leaks the storage it points to. Signed-off-by: Gopal Tiwari --- tools/mesh/mesh-db.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/mesh/mesh-db.c b/tools/mesh/mesh-db.c index fa11837df..896ff722c 100644 --- a/tools/mesh/mesh-db.c +++ b/tools/mesh/mesh-db.c @@ -2384,6 +2384,8 @@ bool mesh_db_load(const char *fname) sz = read(fd, str, st.st_size); if (sz != st.st_size) { + close(fd); + l_free(str); l_error("Failed to read configuration file %s", fname); return false; } -- 2.26.2