Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2077144rdb; Mon, 9 Oct 2023 11:41:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENEeUB4nKUsufJs42mcyJh+s5hUptybVeS+BgO5FKXgvI1XsRqhYpO062ZTvXLCJ2MoKaz X-Received: by 2002:a05:6a00:2406:b0:690:d620:7801 with SMTP id z6-20020a056a00240600b00690d6207801mr14916536pfh.11.1696876876985; Mon, 09 Oct 2023 11:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696876876; cv=none; d=google.com; s=arc-20160816; b=x11LsQhQ6Necesy8gJ8N455/dU8QLExg92rxGEspQLNMUHh/4CKIWJhucMJPfC+oMJ T16k1Xfzd0qZVtYVX+S9+u3XQwbCeHKn5LAIIl86boTLct9VA8vahUkk9pjYrBpNpq24 S0+DYyekBhJwDITfKJVNnFBuPbWvtzN9sRg5++vchMfWXeJ9k6FzlDsOlkNKHDRYRKbR 4sXI9m0mfmXo+s1YlwNMu4rwKo5o7eTmUYkdSaFNaMqCfRcrFaEWgAhlIjG6ZGzw43IW 7GyABwne08d+7WjVM4TrXKQTiS74hLH5u0B856gyhXcLU4438YdBCLdGJumurikQ2/5f 28VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=XtYWHIWRia4V/bq2E7J5Z+6HzWlGjlCMeDuedPRX49U=; fh=8uoRd8OfBKdrcgzCS0TCbKG83gg6rx5b6zeE6Tx82zI=; b=yrY1NMNp93iB/QIujBFFQTqbUzDGutODs6UFNUWlju+iyVC27APi3ENBL40z7+TMKr POXmtDC+HmWg8m6LkvaXRQEMyKjquu7xZQEEX2njyKtZI01wR+V9v5AgT2QJtwD6q07+ ZqlKsFWlI5HALE18QQEGkNcio5baAV8pudBT3h3+KbvpIOYzLqllN9HSP8kpoziry+4z pinqKvqSYFQf00gqGuaSAt/q/4XL7t1UsZVHGz/SqVeOX2j8Mz9tENC4USP0M0o3yA5A jKRNmOH0fC3Z/+XgI+KhfImvHMyQ3fts/fnHGr4fyYHrpvT6c9O8MNZ3sSIZcx4nUNOU l/3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RMvnKqDB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id e65-20020a636944000000b005859d13f276si10257659pgc.569.2023.10.09.11.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 11:41:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RMvnKqDB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id AD16D8104F5A; Mon, 9 Oct 2023 11:41:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378209AbjJISky (ORCPT + 99 others); Mon, 9 Oct 2023 14:40:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378336AbjJISkV (ORCPT ); Mon, 9 Oct 2023 14:40:21 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21965D68 for ; Mon, 9 Oct 2023 11:40:05 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d9a528c2c8bso40555276.1 for ; Mon, 09 Oct 2023 11:40:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696876804; x=1697481604; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=XtYWHIWRia4V/bq2E7J5Z+6HzWlGjlCMeDuedPRX49U=; b=RMvnKqDB/mjYDkfacXxiTR+Rw/13XcLoTBlVP4B9oNuwIR2cYbmI2ne56PbG0IMdvH Qku7WW5VExHXN5VbMd7kEDJgwPFaADs+48N1rgxbrhy4UVxn59V/m+xRl8Q1ACyy+ld6 g/6hDK5HvTa6kcw4i768EL0ONXdRAhajquXngY60hq9U9wa8ibQ3xj7FEY4o5yvuYBHd 9JTEHdK0adN4K1QVPrTtbq3GtevCqZW0x7MVJkWdOajuXOE/1CoobjrGFw5vJCjGQfYT 5v4Ymogh5w9Q3gQ7j4nQw3h5Yh3sqB3H8woDJQBxMQ/GX+reFiy/dw5ys72be3UUiS07 N3gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696876804; x=1697481604; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XtYWHIWRia4V/bq2E7J5Z+6HzWlGjlCMeDuedPRX49U=; b=YhQKoRB4jTF8BY+E/A+FHxz2pJh/TTzdsVVAMsnlUlIRZR8H5QGyy2twRWLkwWhMid PR2SnUDFlFR1bXxRQE9RhsAZVXIDdF+U71Brei8TvtLbFF7x0SV1hiWJn2JnSIHOJ28S OVWQwa0UNuRvZfy4leRt1NjypmmpNsgAewW9beBermaM/DB81Tv8Xm0oHayZq1lBCfuw W812837LlDImep/nYqavfMBvGkmC3fQskWnCXzrIsv/GC1fSksyu/vk6Xiaw9LfAb/MH oWYH3iGrGg5kQDJFem5r0oK0mgNjY5SdEs3iQFMOg6gCXimXTXGuGHbyRikwnLjlcEm4 pvAQ== X-Gm-Message-State: AOJu0Yy4ECVKEtlwRQ/SfrbT2bLBMp0YZ7Q7Q9ShUdA6bShfJiHpU7Dj yF8miEGv5zYpVH1l4JnUAboZi2T8FDtK X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:ac4a:9b94:7158:3f4e]) (user=irogers job=sendgmr) by 2002:a25:ace5:0:b0:d81:90b6:cedc with SMTP id x37-20020a25ace5000000b00d8190b6cedcmr248454ybd.3.1696876804016; Mon, 09 Oct 2023 11:40:04 -0700 (PDT) Date: Mon, 9 Oct 2023 11:39:17 -0700 In-Reply-To: <20231009183920.200859-1-irogers@google.com> Message-Id: <20231009183920.200859-17-irogers@google.com> Mime-Version: 1.0 References: <20231009183920.200859-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Subject: [PATCH v3 15/18] tools api: Avoid potential double free From: Ian Rogers To: Nathan Chancellor , Nick Desaulniers , Tom Rix , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Yang Jihong , Huacai Chen , Ming Wang , Kan Liang , Ravi Bangoria , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 09 Oct 2023 11:41:13 -0700 (PDT) io__getline will free the line on error but it doesn't clear the out argument. This may lead to the line being freed twice, like in tools/perf/util/srcline.c as detected by clang-tidy. Signed-off-by: Ian Rogers --- tools/lib/api/io.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/lib/api/io.h b/tools/lib/api/io.h index 9fc429d2852d..a77b74c5fb65 100644 --- a/tools/lib/api/io.h +++ b/tools/lib/api/io.h @@ -180,6 +180,7 @@ static inline ssize_t io__getline(struct io *io, char **line_out, size_t *line_l return line_len; err_out: free(line); + *line_out = NULL; return -ENOMEM; } -- 2.42.0.609.gbb76f46606-goog