Message ID | 20240213215857.3081841-1-samasth.norway.ananda@oracle.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-64408-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp832777dyb; Tue, 13 Feb 2024 14:04:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW10JmSaWmIYKYJBReHZuB4qYbGjmFc0Zy8TvZ0L+NMPdpIW36P6knFO+FGTr1Et8TInwgsmN51XwUgGzTb4qzEwFHyCQ== X-Google-Smtp-Source: AGHT+IFv9MsCXxckncM2RI9xTlg3FsqSDIjpTnw/oEwAAqdVCk9LrYhI0vMy15PQEsRzvINz4Hgy X-Received: by 2002:a05:6214:5012:b0:68e:f594:30ce with SMTP id jo18-20020a056214501200b0068ef59430cemr895131qvb.25.1707861858531; Tue, 13 Feb 2024 14:04:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707861858; cv=pass; d=google.com; s=arc-20160816; b=I+iJVG8jqQUIhcAiySzjurwqT67cAev3v6VnVBpvgfe/Ud5jp9xmL1n5bSMR33s/Dm hXnxdpQicJUGMO0XK8TcfEQnCm7N2G/4POBCk5xmmX2M2HD0VoXuV5H/tXhpJ82olrdX 2lxNuDsFCYm5J6HkWLN49V82yLorpijOdBjGSqRp0LS9xXJZ5lkQeenPsiwozk++xlbU 2C0W7/J0ZUBaNQ2j97N4UAZy0doHhpieZ/kUJOURufpCXo4GSEVNNW0kUH0x0Etn5rOS +E6hLzDmpfUcHLon6g1R2/pEz2rwngFvzCBNbpWcZJqapcnmzxVDL+1zyuw3N+0ueLJ3 wIxQ== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=ukCGGXI9Jxb1GstaggI2PMFSAmqWV+ZT0DPIrBgA8Ns=; fh=4/eFW4pc+4TqqoX3Ez2Ut18SY+DaP/ybxaaiIdXOnv0=; b=mK380Z6W43Q331EAGJ5r5MM/cZ1wfVp8I5o0eOSzezc8l5HKegZf4jLbDRUzBe1jb+ gB1kEXdj3oTozawI8HI3ubvAP0cFPoRaGK4Y701k6YQv3bTMKx54VaZ4VNc2i502yxh7 pWX6rYm+Q8NIH3A1C8bwS6q2fE38/Z+jmrZJ3H12Mze25EK8HMVAKf8g1kgEoPA4A8dS RuybySZFomU7p2ekfYZT3FbKYcELjWMT4y9/2sb4mIGGQz290pvkwzCYzzZj5sM7pRRM kFz2nkaQOWoF43WUHL5iVaT8p03zwtLYedQfDyZ/pbKLqwnK8dUF1IvuAcu32fQP0hdp 7T/A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=hFwIPqHd; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel+bounces-64408-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64408-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com X-Forwarded-Encrypted: i=2; AJvYcCWSE9AlPuLBRgK1AxePv5w3PhrKuU3UJgEADHNtVi7rjMU3KZisuulE1E1xBn92lS8/LQEzuDXgUDj08Ijqk8kPEKtekQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id gg13-20020a056214252d00b0068ca7dc680bsi3736933qvb.366.2024.02.13.14.04.18 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:04:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64408-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=hFwIPqHd; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel+bounces-64408-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64408-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com 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 F06311C20A84 for <ouuuleilei@gmail.com>; Tue, 13 Feb 2024 22:04:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 68F0B69D05; Tue, 13 Feb 2024 21:59:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="hFwIPqHd" Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 5B9FD69D00; Tue, 13 Feb 2024 21:59:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861550; cv=none; b=f6LkcAkr73xXd7di63hR+uJ2zhE3x6zi0LhBlegOjasuYjfN9YWac2aRMygkXnb+wvniEI0LjJN1BSp7RWBuJN6nAHOTMn7oTbd2O6eHMQxFJ5FWcdcLgR8WVWAqsOiJ4GHKovTTEsL0pCFGcXYS+Lfeief2wVvcWiAsxORIzYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861550; c=relaxed/simple; bh=JJZKe2t0kamyMzVROuPedbDxFm+zHMjxwqHfKjv86Vs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=hNNx/AKoi6sNludGWLhIl+rJF7ZEZIkprNKtEAd3LJJvsCHg7Rb4ZSPKAZ0C6m9b9I2Qiuy8Q3ty2gGtoegGsrkkdFVSUaRrjSgpIX+WRC6IkDAoiAxttn98ei4rE5+k7y12cbbeyxsa0Lnm+CsjYeheuRA9FakQLOvp60SRxuE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=hFwIPqHd; arc=none smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41DL4fIu001929; Tue, 13 Feb 2024 21:59:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=ukCGGXI9Jxb1GstaggI2PMFSAmqWV+ZT0DPIrBgA8Ns=; b=hFwIPqHdkoDZYsVMHJ8zXgJ+TLgjlWOfxhztM+UJgYDB/AWOR/3a984ul5nwA8gnexMD i2V7x9UOLzu2YlSdaCrIH9yAZYVhuetntb8L1SNgT0bRzg9aLZ6Mwr5D0guvTNOudA+x KLXRDsLvFFFnEsrHxvZ5LGr6B4+jFRUu/i2Cd3rwZ/NskzqDODb5HID+pXZL7ryJ4m9f VVixqT6zm3xj70AINFvCMrEjhDlRvMkXBtLayIl7LXq1EX5gk+fG9NBUmer1bF3WPTrS kF3fRfvr/fZeyerU0eCJZO+rqqbCZL/2B8iGMaTBVKg+oDziNTRRhbiMtBRgtlApHTud Cg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w8cxr8p2w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Feb 2024 21:58:59 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 41DLFAtr015276; Tue, 13 Feb 2024 21:58:59 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3w5yk80tj9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Feb 2024 21:58:59 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 41DLwwaX037838; Tue, 13 Feb 2024 21:58:58 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.129.136.47]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3w5yk80thj-1; Tue, 13 Feb 2024 21:58:58 +0000 From: Samasth Norway Ananda <samasth.norway.ananda@oracle.com> To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, jolsa@kernel.org Cc: samasth.norway.ananda@oracle.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH ] perf daemon: Fix file leak in daemon_session__control Date: Tue, 13 Feb 2024 13:58:57 -0800 Message-ID: <20240213215857.3081841-1-samasth.norway.ananda@oracle.com> X-Mailer: git-send-email 2.42.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-13_14,2024-02-12_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 suspectscore=0 phishscore=0 adultscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402130173 X-Proofpoint-GUID: UmyLGXzZ-iwIc4jmZcmbUW1efb5iKuvz X-Proofpoint-ORIG-GUID: UmyLGXzZ-iwIc4jmZcmbUW1efb5iKuvz X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790822956459976979 X-GMAIL-MSGID: 1790822956459976979 |
Series |
perf daemon: Fix file leak in daemon_session__control
|
|
Commit Message
Samasth Norway Ananda
Feb. 13, 2024, 9:58 p.m. UTC
The open() function returns -1 on error.
'control' and 'ack' both initialized with open() and further
validated with 'if' statement. 'if (!control)' would evaluate
to 'true' if returned value on error were '0' but it is actually '-1'.
Fixes: edcaa47958c7 ("perf daemon: Add 'ping' command")
Signed-off-by: Samasth Norway Ananda <samasth.norway.ananda@oracle.com>
---
Found this error through static analysis. This has only been compile
tested.
---
tools/perf/builtin-daemon.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c index 83954af36753..de76bbc50bfb 100644 --- a/tools/perf/builtin-daemon.c +++ b/tools/perf/builtin-daemon.c @@ -523,7 +523,7 @@ static int daemon_session__control(struct daemon_session *session, session->base, SESSION_CONTROL); control = open(control_path, O_WRONLY|O_NONBLOCK); - if (!control) + if (control < 0) return -1; if (do_ack) { @@ -532,7 +532,7 @@ static int daemon_session__control(struct daemon_session *session, session->base, SESSION_ACK); ack = open(ack_path, O_RDONLY, O_NONBLOCK); - if (!ack) { + if (ack < 0) { close(control); return -1; }