Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp151831lqo; Thu, 16 May 2024 02:04:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXhEFACfy+hJCA0oXyH6aJmD72+Y6PMy59R4/5DnMli9MmVBDsPoRPpHqKBjiSnWpJ3ThBLxD2lSTbLYlPbmBDWntFSttFsik7R3NvcTQ== X-Google-Smtp-Source: AGHT+IFKFucdS/hKbNwGeq8ztek9yfRAkrJuw/G7HnRKRjzaubEOJR5rDE+8fYLMZHS1/zb8OZH0 X-Received: by 2002:a05:620a:1709:b0:792:b96d:370b with SMTP id af79cd13be357-792c7576022mr2346381985a.13.1715850269341; Thu, 16 May 2024 02:04:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715850269; cv=pass; d=google.com; s=arc-20160816; b=LTGoZkp2x/+IZf4YNq31qKF5DXC4JujUA0x8aZ4ojWgot8zUGntBmd43rT7pbpQg1B xN3crMWqcq6m777jrIQr7g38ItUvBEZ0xMlchUtQsDIHiSbG8kSltXJNk8DWLucogYXQ oKqgLIntnn38gfGL3hT+iZvjvNuHBMNzi3RsHbXEA+qN1ovZkOxUtTzAqEs2DoYiPZw9 72/SxD30zajWxol0oB379R2gTh/zEya/qhx2tiil3ZchDJMoMGqy9z5zsyMJLwAztUws ber/FZHmB3PunDMFtpap1eGUt8JC7KKTjRfKKHIO/0FCt/6K849ipwmrLS0uzQ9z2eua H7pg== 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=zQRIa6KEK7keoKhRgfEFUX0clO68ozcNRc4XRUYPj7o=; fh=uo5u2TQK/HQlhydMwGLjBAnuDwaLxndJ/cgWTjIagS8=; b=apZBBwafYmW6Svvs5V8kROGAz0rtmgdsbQ7SvuuivvdmXowxH+EceES8f+01LgBTIf bOmC/dji7sn2WzFeg+dWwX9hq5TKPplT4P7jzRs8a9olBtqRVq9OAQutwVIQYpi0S9FO 5d9bA5TDM1qfdwN4sygvwA+nIRPztR5AXe/sCXW16cw44Yng67FJnNxCpXmpk779k72x mhJYVOS9G2EH/MnbhRxlUG6XAS+Nczqb3jnZVUy+A2wqQHIRhNBTmicNWpidxSJlgb8M OJUAle1T6i2rKH2iRk7x/h8MpRF0juXaYQPf4zhZGuyacsnVEUPBbj/uh+g4F4sT3+UW iEAA==; 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-4695-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4695-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792bf38de3bsi1605239485a.780.2024.05.16.02.04.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 02:04:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4695-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=hadess.net); spf=pass (google.com: domain of linux-bluetooth+bounces-4695-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4695-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 166B81C20C36 for ; Thu, 16 May 2024 09:04:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55F7F143870; Thu, 16 May 2024 09:03:53 +0000 (UTC) X-Original-To: linux-bluetooth@vger.kernel.org Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 8061D142912 for ; Thu, 16 May 2024 09:03:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715850233; cv=none; b=llrqvyt0gyDAGsY9E1x/nT7bQOLPXq8/qW4xgMnNVhtLWTgrLomcW0i7KukS8zyuLmb93EUD8JQaYpgbMCZWoMIPCaSD3ACf4e0qJpIKmcjEtHT0zyaTPh0CSGlac5OmN1lgEwHPTPRgbjqz97DG2eiPx+oZ1n/0MVedDKYc9AA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715850233; c=relaxed/simple; bh=d1o3XOd5RyFGZH2VnJi5Sb7N85gZFU73tOOQkeoxsig=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PObvqe3yBwEf7GwfmTXPnoNAIUWkaEQoMYKFFLYEPzql7UU+tp+AyiW+jIMcOnJhY8u5tohLiHy3ua7e4g/bBGfFdCLogjiWH7ZqfSJ+puZbwvMCmr3hx2DuzYpdT4Rst2ht8dpzgR54vdWv+1L1OBtP9ZlFcmt9vpJXdrZFSIY= 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.197 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 F13FA1C0012; Thu, 16 May 2024 09:03:43 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ 10/15] test-runner: Fix fd leak on failure Date: Thu, 16 May 2024 11:03:14 +0200 Message-ID: <20240516090340.61417-11-hadess@hadess.net> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240516090340.61417-1-hadess@hadess.net> References: <20240516090340.61417-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/test-runner.c:877:3: open_fn: Returning handle opened by "attach_proto". bluez-5.75/tools/test-runner.c:877:3: var_assign: Assigning: "serial_fd" = handle returned from "attach_proto(node, 0U, basic_flags, extra_flags)". bluez-5.75/tools/test-runner.c:955:3: leaked_handle: Handle variable "serial_fd" going out of scope leaks the handle. 953| if (pid < 0) { 954| perror("Failed to fork new process"); 955|-> return; 956| } 957| --- tools/test-runner.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/test-runner.c b/tools/test-runner.c index 908327255ad7..de0f2260480c 100644 --- a/tools/test-runner.c +++ b/tools/test-runner.c @@ -952,6 +952,8 @@ start_next: pid = fork(); if (pid < 0) { perror("Failed to fork new process"); + if (serial_fd >= 0) + close(serial_fd); return; } -- 2.44.0