Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1235436lfc; Wed, 1 Jun 2022 12:36:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwY11OEdjgcQKGobn76Cx+H7jZtxHG6bFa3RWk7DDG+DOdKK4LHE6+aPPBM5EcmQf9YF2DN X-Received: by 2002:a17:902:aa4b:b0:164:11ad:af0f with SMTP id c11-20020a170902aa4b00b0016411adaf0fmr1037262plr.54.1654112174700; Wed, 01 Jun 2022 12:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654112174; cv=none; d=google.com; s=arc-20160816; b=gVwaWwyFjqivOmXDw5M3bIuyv3zPvMyOCLyTBKR8gNKkjyuHN50XfB6WCNNquGLwQR nxMZGE4fc+Pl4Qb/BTCtKGk7Y4hphBdc6DPUYBBxWhdST9mBPT0qwBzdWJLdb/zKya4v G/mBcg2i4NEbgCLxnUsrF8YYfaSdoMBdk3qvjQiRYnKCzWEs4EUaXVyDxrmEDn6MiRk4 F4aVpbBzTBvwXF43tNlfY4W2yuVlIVsWzKKzLDP/k5DmUMdYriab/FoZmSVoomH5wHe7 EqVyfMez5qDXcMwDb3I3wp/yoi6JEFpjwhZqeL3LuEPsHNY585L9Ep4yuxZr2Ognes7v a5fg== 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=BbblSBzbaF6BOJ6iDpVRG6wnq9RsQ/MylB6LPmp9Uh4=; b=C03isWlkh09mqOqJ9VnyuobLgrVEOU0c3uSsTWz6riLPhb7k68RA/uFYeuvaW26Wqt YvLt90KuCw4v47OG9Yqy38gBcNWNgZ5PV58KEN6YhL0zS02N7SVeT98+/96zLAM+1zf5 D5W1V4oZxrqThPK43Wttx2yCpI4t5gHzK6q7dyNDPDTLdhQyryW2sLtuyyNPu7AkfXbw QuDa0PLbAmtuUsDI6YJwyobzoJfSPvZsbWVKK6E6pWJSzDoQsBd+qqsEHEy64cnZ7UDK f0FHhocN+dSHsxM0pcBBKaySbBrTrjI45lYUyDgeqLIHrz8S3nf+doDU6626wY01/bCA 0fkg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-bluetooth-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j3-20020a635503000000b003c65dfad4afsi3165605pgb.367.2022.06.01.12.36.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 12:36:14 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-bluetooth-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-bluetooth-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8F197F749D; Wed, 1 Jun 2022 12:05:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244565AbiEaHln (ORCPT + 99 others); Tue, 31 May 2022 03:41:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244563AbiEaHll (ORCPT ); Tue, 31 May 2022 03:41:41 -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 979C6D8C for ; Tue, 31 May 2022 00:41:39 -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-640-d7R50c5xPaqnTyHzF-qf8Q-1; Tue, 31 May 2022 03:41:34 -0400 X-MC-Unique: d7R50c5xPaqnTyHzF-qf8Q-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 7881A1C0897D; Tue, 31 May 2022 07:41:34 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.64.242.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 384C91410F36; Tue, 31 May 2022 07:41:31 +0000 (UTC) From: Gopal Tiwari To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, gtiwari@redhat.com Subject: [Bluez V2 03/13] Fixing memory leak in jlink.c Date: Tue, 31 May 2022 13:11:07 +0530 Message-Id: <20220531074117.610321-4-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.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,SPOOFED_FREEMAIL_NO_RDNS,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..f1d8ce660 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