Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp452087lqo; Fri, 10 May 2024 05:15:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5Uh4SfxxWOFCGUvN000Gg7oPxHiNW6DLoHfRK+gpscCScfknaexy0mDcEW9XMpE0YmcoymGcT2/q0BUIzqk/vBOqkyDVEsw9wTNLJ3w== X-Google-Smtp-Source: AGHT+IFzoKj9Zqy/XLsQyFCotJ7h3MXlikfYWNeF4G4yg66Fn/8EphdF+VyAzYUMNCVDT/TOftER X-Received: by 2002:a17:906:560a:b0:a59:ca7e:e24 with SMTP id a640c23a62f3a-a5a2d641767mr164875966b.53.1715343300449; Fri, 10 May 2024 05:15:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715343300; cv=pass; d=google.com; s=arc-20160816; b=pLUrr+i+EmpAefzSIXTf1W8EDI8Ux4cMTwtonUNw9s8WPn7vfw911cTIkGg4OR33hJ mZ1DFraP/ATioiPY1W2NdoLQbdGTEIk9tl3RNWIb3vJY8jFMtCD5JD3WwfgxHM9qxYaz tE6Up04A5gTxAHVLEBtTwJYxQPHpEhGpXtw+22HvfbObuC6s5N/aap5n9UPxUYNgJVzu XznbZFVPzuHCyzJPaysF+etNz+Fn30ooE8AC1N63dFqG7BFaAOw4QB2Pefjkz5X2RTrn lHazDaySUrmKe/tFWrnrHfmm5LAfqs7a+I2dcuveTnigH4EWDyDuooPjgzcgQYy+G1wJ DQKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=5XjpZBBne3jFSNeWefd8fi0wEZXfMhY4Mzik1iAnbI0=; fh=uo5u2TQK/HQlhydMwGLjBAnuDwaLxndJ/cgWTjIagS8=; b=iupi9tLnPQi82XtYm9kzT1jdItNYu/BshQlxFF9X371scdA/um1lqrCrskRdQuh+jZ EMIZfdAJyMcSOvBKkUICooBMhaVdETdCxGCTO9PrE8bSgZbXpvNOmti1as/H82e4HgSL V8l9w9tGxprlRcMKd0g2Z2EU4u5pP2NpRJrH867OwjBnXeMsUokuPKiaWmyc+rAl5u+J lw9WyR/7HOPi5NViWth1wDxzkhisfsdflMdO9mpXdFFU1TdFcgThizwAbqu0N65aUuhV qTdn8Ee0FcvyT59GSoVzIONcblfFuYXvh68kFdy01Q+B/Ud5q4tiWKAU97KW7L5o+P41 Rkpw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=hadess.net); spf=pass (google.com: domain of linux-bluetooth+bounces-4481-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4481-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17be6ec3si178132866b.818.2024.05.10.05.15.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 05:15:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4481-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=hadess.net); spf=pass (google.com: domain of linux-bluetooth+bounces-4481-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4481-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 33F5A1F22B4B for ; Fri, 10 May 2024 12:15:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B2DAD1708BA; Fri, 10 May 2024 12:14:18 +0000 (UTC) X-Original-To: linux-bluetooth@vger.kernel.org Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EC0C17084C for ; Fri, 10 May 2024 12:14:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715343258; cv=none; b=ITN0BAUpS5rKpUtcCRPwvkR6xkZYczCBxbFH7aYLQuvlK/f9CyNNJB038bSyGjnqkrhD37V8Izi51ynxE0awDUWZUVF/uZ95wLI+jLcxRmxeNmNwVBfszrkUE3h9MCVOdAC4P/GN6N2VCdYvYMI3aDWH2UHswaAmxBW28cw+hx4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715343258; c=relaxed/simple; bh=1b+p1b7GIT78GDQGbHD5A5ndMiK4C9pGS2ldUhTTJEU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RxeEFqw4aAFzI3Pfmo+9q1eUvPdRqZ8A6aQtNtb3hh7xbuimqoIEJXnj1EamIGrj2/c6VHZNmEAbDWiS/VK3kQTWWouEQkfR7yydGQ4lji6t1+LrVpwwboKKg5MGCOibnIWYrdmdP97mvy0gkBNL8gjCKZ+6L2DmN64A3O2W/zY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net; spf=pass smtp.mailfrom=hadess.net; arc=none smtp.client-ip=217.70.183.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hadess.net Received: by mail.gandi.net (Postfix) with ESMTPSA id 3ECB260014; Fri, 10 May 2024 12:14:00 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ v2 15/20] isotest: Fix fd leak Date: Fri, 10 May 2024 14:10:25 +0200 Message-ID: <20240510121355.3241456-16-hadess@hadess.net> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240510121355.3241456-1-hadess@hadess.net> References: <20240510121355.3241456-1-hadess@hadess.net> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: hadess@hadess.net Error: RESOURCE_LEAK (CWE-772): [#def65] [important] bluez-5.75/tools/isotest.c:923:4: open_fn: Returning handle opened by "open_file". bluez-5.75/tools/isotest.c:923:4: var_assign: Assigning: "fd" = handle returned from "open_file(altername)". bluez-5.75/tools/isotest.c:953:3: leaked_handle: Handle variable "fd" going out of scope leaks the handle. 951| 952| free(sk_arr); 953|-> return; 954| } 955| --- tools/isotest.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/isotest.c b/tools/isotest.c index ddace0da3044..58293133a304 100644 --- a/tools/isotest.c +++ b/tools/isotest.c @@ -950,6 +950,8 @@ static void send_mode(char *filename, char *peer, int i, bool repeat) close(sk_arr[i]); free(sk_arr); + if (fd >= 0) + close(fd); return; } -- 2.44.0