Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3419602ioo; Mon, 30 May 2022 01:24:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwyB1tB8cPdl2HOBMkNBJHRH52nnF0jFtzXAzOOI01tHu2HpHyZb8iosJsBZkzOPKGbIzc X-Received: by 2002:a17:907:7fa3:b0:6ff:7867:8071 with SMTP id qk35-20020a1709077fa300b006ff78678071mr3880592ejc.411.1653899058880; Mon, 30 May 2022 01:24:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653899058; cv=none; d=google.com; s=arc-20160816; b=LkUeO5K7CYYsAVh3zwas30gPrxGTF6UzB6LhTk5G08DShwD2UprA4n8GJsrZcmNQJ3 f5cet09PTWt+e+BSESSJxvQzyYsfF3I33Ve9sLfqTJhEDKpbLCxJH6uobDb8utQBD33m bCnx0HqpuYIGT4MVAMuwhpEAgLRUHN/afnZQz9EflbFlrWfp55w7sl4nVh4ZvE5hcPZ1 piEtG+jVHPbx4VXgkHi3ZNdftEhT+qPjBx0hkdz/5JB2gc77LbLk447V8+8gU7R1XOF2 cRFFuifts8Vaunfr3lOOrh31Q9pMUlZ0e7Qw7T9zQrIMYnLlGG1X2klJfxEpU7b06DC4 PcQw== 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=Gac0//PNr//lfihH7FcASj/RvbnY/6OYyoMDYdDopx0=; b=BT0nRe321NHFlgzv4pxPDgKAL39PEbpLVdIe/4pD5DtZhuen5eUl6YrxbtqeKNuDPk pYYtz+W2s8GpbQd2bbvpzltKIqadP1kDCbgWaVb68ke9QmXHoi4I5AElGFGbyT9qzapY WavkW3WT+mKV0vAlLtGVir0/xss8mKBWWom1fZZqn67Kw91u3FvwdauA8cr19+X1o25G EBJpFWAsUfzIXUz3ZICRSQQjFZyy/xhyfl/EA9yyI/UUQqgCsbgCtjBJGCT4BOIXlZSw mq4g60nXf6Gsk08QH4xXwKLDbT+nMBbghNSsvdQQ6/iYg9yHU9Oh6O5u2o6xBii1VqO6 /5ew== 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 hq10-20020a1709073f0a00b006efdae095adsi12942550ejc.954.2022.05.30.01.23.29; Mon, 30 May 2022 01:24:18 -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 S233250AbiE3IMy (ORCPT + 99 others); Mon, 30 May 2022 04:12:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233309AbiE3IMs (ORCPT ); Mon, 30 May 2022 04:12:48 -0400 Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [207.211.30.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 681FD6EC4A for ; Mon, 30 May 2022 01:12:45 -0700 (PDT) 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-17-UGt0DmVlMEymLthO7_-CBQ-1; Mon, 30 May 2022 04:12:42 -0400 X-MC-Unique: UGt0DmVlMEymLthO7_-CBQ-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 D64B0101AA45; Mon, 30 May 2022 08:12:41 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.64.242.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACD1C1415100; Mon, 30 May 2022 08:12:39 +0000 (UTC) From: Gopal Tiwari To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, gtiwari@redhat.com Subject: [Bluez 08/13] Fixing resource leak in mesh/mesh-db.c Date: Mon, 30 May 2022 13:42:04 +0530 Message-Id: <20220530081209.560465-9-gopalkrishna.tiwari@gmail.com> In-Reply-To: <20220530081209.560465-1-gopalkrishna.tiwari@gmail.com> References: <20220530081209.560465-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