Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp288576rbe; Wed, 28 Feb 2024 22:21:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUfLcCTiv1OiNOyPul0ThYxN+SnJxAkighpytYmLGpYGPoFuH6QUB2hSafMU1RpWh7PqV67YoLrwCfTr8LBMB+Wbu3ieXSWnQgmDC7b6Q== X-Google-Smtp-Source: AGHT+IHAwNXF/KwaO545s7gVPrZ1hZ1rPo36IAHT3D5870jtM09duCTKfYwK5gDkQ8u96/ibPrGx X-Received: by 2002:a05:6902:cc9:b0:dbd:be40:2191 with SMTP id cq9-20020a0569020cc900b00dbdbe402191mr1572177ybb.42.1709187672915; Wed, 28 Feb 2024 22:21:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709187672; cv=pass; d=google.com; s=arc-20160816; b=KIkWe9d1vXa9XJv5Avake01OMmQJQlXwxioVIo/uEaivx0tHqLCUqWLRXrMcWmECrk vWzO+16O04lcxLPwklElP+I4y8hUuCNxOitBeOsSlhj62YQlWN2x49K4VAPJjV8M6mal alB8ia9+ND2D0X2zXPAWvtNQtBvDWls9TOulXsm10KeA59MI3TciMgVGD4Yz24J3si3i rHGD0SQi34yTJpRFcesMBEf/ctgtBPxQlbQCbvy6MX+JHxtrhdGyLjp2ZEcpw/9/CQ2F G4htIyB6E7w1YKwoAoDs7oABk1Y9MzK4T5spxHt/g+82VsDHxOS7viJJS3V1bafxhyrs gglQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:date:dkim-signature; bh=HP7FHTSIsiaJThzWBkYLUGihLpdmeLYVXFRi2ap+AOo=; fh=TdLTyXh0iXrIRZcB+/oJtX1a/0Zxu6NsGqy2yog7XTw=; b=PgROEtkgPOWWdrdKflmaF7TjlFybePhWfoMq/h3CuSChtqjkF0syHnU9XyVsKOZ4iE z5AgypOER4JU+ECk/w08jjoGkthVbdnclYOwxGxkp+fWQdbvnntP9Ja4I6n3D5MrfLk2 bJJ+i9oTfhLu839ADT1Ba5XroDiyXddbFZpcNYXymfqggoxjDFHO+U0F0jJHW0bfVAiJ 4mVc7eUDDsul6z57FqU3LxfZIusRsnvJe0OcETNBqZnpkMjlmEL6/pv4qAPp/EwsOCy/ IDHkz/uVDJ1mQjG8M3/ZsAcLnGqxZzk1MzDytKX0mtqlM4BosB2DNtzVyVplSDOrP71z eoZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Q93PgiMu; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-86162-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86162-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h20-20020ac846d4000000b0042c44c065e6si722390qto.733.2024.02.28.22.21.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 22:21:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86162-linux.lists.archive=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=@google.com header.s=20230601 header.b=Q93PgiMu; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-86162-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86162-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 A7A711C2199A for ; Thu, 29 Feb 2024 06:21:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A36A33C49A; Thu, 29 Feb 2024 06:21:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Q93PgiMu" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A9C136AE1 for ; Thu, 29 Feb 2024 06:21:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709187664; cv=none; b=JxEmqH0Wr0reLBzqN7DmqiWkHBxR7ut9xvu6H4n5ww8euwYnwO3h43ZCldtonHfcSKU6dC+aqUb0wAgqMSY5iwK7oWoxZmRq8ewCCTbwbEYx0+IJaIso1j78XdCwss6ZnTOKUwgjJE52AVfJkZim8J3kZcLU0P6B4SX+kS0ERpo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709187664; c=relaxed/simple; bh=rWfMlMwr/8u2RrDewjX8624dpgZQiC94SLvycpO6+Tk=; h=Date:Message-Id:Mime-Version:Subject:From:To:Content-Type; b=odCwG8ayQc5zqiKwm/zUsZWaFPzLbDchJNsEhtYqvA1wurq25VpEpWw/mDnbAgenT+GRIfFLmb0sSPdlHiwrf8i91HFI57f2/9ahGJGiwatO7Q7uqLgpDZzyuv8wRzWtIzCs3sZUaG8rxfv8lkH8xQL4ek7f7T7QK5MT4KilN+0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Q93PgiMu; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dcc4563611cso1060677276.3 for ; Wed, 28 Feb 2024 22:21:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709187662; x=1709792462; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=HP7FHTSIsiaJThzWBkYLUGihLpdmeLYVXFRi2ap+AOo=; b=Q93PgiMuTNFHaFBMTT7q9IYkbqBn6uQBFPZFiRtHrLrnA3s4/gYDUZBLgjduFT37rP NPWumPy5yNM+/K56ZIBF9ll3YYvsmm9zsX5q3+Fj67Z78eyewYvmWlA4gjNebUhOdRbz BxwfYAxh/GocDQXt+oIsFPP5Eu1TbzBSFkKlIb7XAh0E2XZvPR+PgbAPXqn4uxpXVyAB tVcEORGj0cEEtexjZTsWJnMmhG4GL2PGlq+bSSUEZ9MgRJwR3tkMnFliXSAMMu5jRhBu b6rLBUQuZowiUqqik9g3H8nrYBSU6WBX/47YDnrFmrkEOQ3oin1abYzOJ9Ezp6UyTO9p LLJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709187662; x=1709792462; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=HP7FHTSIsiaJThzWBkYLUGihLpdmeLYVXFRi2ap+AOo=; b=n/vQPj76WOQW7aJU5obSS2w54WGnPH/PFlJj+MCeDFRrDV5PjIA1MaWsH75E97gUwR GOUjlr6IFf8+RD25KZ3aUoQQyfxNajj1xBYWjz+2uzQbuFO72bNA0KIzhL7yPTxqlLSL 3y5PcGC+q9vklJTHQxXIKpVZjqntWPrUaeninZFEOfK5qeRNSHE9KyoIIJHv7Sje9rwL BkJ0Y6g4ZDFMIY0JDvbjbZeDpACi7NT3KwMPkrLzUpngKgY++4hyC26lUjtbYHGqWXgB TNLKSZHa8zsH5644ivtALcBI6KJPxSitpBY4NNxIU+eae0B6B5RoSN52Cnu/WYlQWkGC ReUw== X-Forwarded-Encrypted: i=1; AJvYcCWItcyCMxBUmHLjnSd72kDrZQzN7KR+ye5GAQsThPrqLmNU5T5sHmzZRhP3w+l0ufLJnm2CF24LVb1B8yIoccNSzAw7OzxcvfjbOiVn X-Gm-Message-State: AOJu0Yy7ZckTAa8WlyPgNQ+ufWbi3M9Kp1fVUfPxdfXy8eNJl/5uHDPg kbgLtD2Wj+3YDgAuKgFgk9ejIED8k1o5LMNX3PCTp4DjhROfuUZ+V+QKMEoqZXtQv5p0jdQsSn9 Axws1Xg== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:188d:b0:dcc:54d0:85e0 with SMTP id cj13-20020a056902188d00b00dcc54d085e0mr369155ybb.11.1709187662515; Wed, 28 Feb 2024 22:21:02 -0800 (PST) Date: Wed, 28 Feb 2024 22:20:48 -0800 Message-Id: <20240229062048.558799-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1] perf map: Fix map reference count issues From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Masami Hiramatsu , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" The find will get the map, ensure puts are done on all paths. Signed-off-by: Ian Rogers --- tools/perf/util/maps.c | 14 +++++++------- tools/perf/util/probe-event.c | 4 +--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tools/perf/util/maps.c b/tools/perf/util/maps.c index 53aea6d2ef93..ce13145a9f8e 100644 --- a/tools/perf/util/maps.c +++ b/tools/perf/util/maps.c @@ -611,14 +611,14 @@ struct symbol *maps__find_symbol(struct maps *maps, u64 addr, struct map **mapp) struct symbol *result = NULL; /* Ensure map is loaded before using map->map_ip */ - if (map != NULL && map__load(map) >= 0) { - if (mapp) - *mapp = map; - + if (map != NULL && map__load(map) >= 0) result = map__find_symbol(map, map__map_ip(map, addr)); - if (!mapp) - map__put(map); - } + + if (mapp) + *mapp = map; + else + map__put(map); + return result; } diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index be71abe8b9b0..2a0ad9ecf0a2 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -2274,9 +2274,7 @@ static int find_perf_probe_point_from_map(struct probe_trace_point *tp, ret = pp->function ? 0 : -ENOMEM; out: - if (map && !is_kprobe) { - map__put(map); - } + map__put(map); return ret; } -- 2.44.0.278.ge034bb2e1d-goog