Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3503677ioo; Mon, 30 May 2022 03:39:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjU9a3VzX8yX2SqMS8/RuKE26KElrLiAuv9wfN8P0rQTeLhFnyuHpWKvuhs73UcFbRe0Zj X-Received: by 2002:a17:90a:df16:b0:1e3:1cd:6c6f with SMTP id gp22-20020a17090adf1600b001e301cd6c6fmr3975651pjb.10.1653907161142; Mon, 30 May 2022 03:39:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653907161; cv=none; d=google.com; s=arc-20160816; b=TTXmEAwWFd2Ic4lpFv8ML4c2fVlCWeRSbvctjmgH8emEE7F2Wuvf4FcKx+x7qSpjJ2 LnfkmNjBo3UlA8CEN/iNAS4tA9FkiAcRlhE0p+RvkyRE00UtFZLxlZPYo2IJsQpWVFzL JDd/XvWIzRVzF+Vy9aRdvQqjnlpXLLJTU3MLbrPhePTn34h2nb1Ko+ms2KRhF0y5p0Q+ hNvo/ediu/30Bun/0an7sbaFO5vVYIgdNHcn2bCCeSopSNNMzB+6uQwOj5sg6uZnuMo8 NDZrlmoat3Wxc+v4fdfUCyER9ptLd/ETT8HJoYNcBCLMBs9eFE/ejSY4Ktf2ItxqN2ii UMpA== 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=NlFXg74ioaUJmhsvAQktg77LZ5YSCH314NTvN8Cxzzg=; b=fdorFH39L8uYtbfi3WDZrighfBg945tgB/9UbbLoeoeCv4RCDiQe3Di6wp/IM5upuO OO9l1zT6MkapE0bLUK7ebNd9ZfNFc3FdgQVWOacpMnka+asgQY75m8SqVbmGeeHA826Q WZwpt7FebLf6y2vVGGqoEGCyGwN76nkK8K7gqfWTzQQxeXTxPYj0D0O+azXifMxwzm4l HPDT3eNTdbabsxpy0wuTw41QEnJuY/ncothPXdkWw19285bJ7Rk8iG5OctP0gX7dyhPD 8jv5NsbHwh21C4bRlUrVkj8ntploBU8qZYFPyvJ8lU8pK8tKJfEZObv7RboVsuIcWIWP rytw== 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 bf8-20020a17090b0b0800b001e2fab4d1a9si3482212pjb.105.2022.05.30.03.39.06; Mon, 30 May 2022 03:39:21 -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 S233169AbiE3IMa (ORCPT + 99 others); Mon, 30 May 2022 04:12:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233178AbiE3IM3 (ORCPT ); Mon, 30 May 2022 04:12:29 -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 C57753151E for ; Mon, 30 May 2022 01:12:28 -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-145-82c8eLv6MkisC8Hwy_VHcQ-1; Mon, 30 May 2022 04:12:26 -0400 X-MC-Unique: 82c8eLv6MkisC8Hwy_VHcQ-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 3176F3C02185; Mon, 30 May 2022 08:12:26 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.64.242.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB8671410F36; Mon, 30 May 2022 08:12:23 +0000 (UTC) From: Gopal Tiwari To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, gtiwari@redhat.com Subject: [Bluez 03/13] Fixing memroy leak in jlink.c Date: Mon, 30 May 2022 13:41:59 +0530 Message-Id: <20220530081209.560465-4-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/monitor/jlink.c:111: leaked_storage: Variable "so" going out of scope leaks the storage it points to. bluez-5.64/monitor/jlink.c:113: leaked_storage: Variable "so" going out of scope leaks the storage it points to. Fixing them. Signed-off-by: Gopal Tiwari --- monitor/jlink.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/monitor/jlink.c b/monitor/jlink.c index 9aaa4ebd8..672097004 100644 --- a/monitor/jlink.c +++ b/monitor/jlink.c @@ -107,9 +107,12 @@ int jlink_init(void) !jlink.tif_select || !jlink.setspeed || !jlink.connect || !jlink.getsn || !jlink.emu_getproductname || - !jlink.rtterminal_control || !jlink.rtterminal_read) + !jlink.rtterminal_control || !jlink.rtterminal_read) { + dlclose(so); return -EIO; + } + dlclose(so) return 0; } -- 2.26.2