Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3783306ybi; Mon, 29 Jul 2019 12:32:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnOMb4QL5E9/Ha2fdxEK1LwTMtTvi15Bxw0622mtYRT7MbKuZNqYM2LhkZ5cCxn7HZPzXy X-Received: by 2002:a17:90b:d8b:: with SMTP id bg11mr113715417pjb.30.1564428754238; Mon, 29 Jul 2019 12:32:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564428754; cv=none; d=google.com; s=arc-20160816; b=LGBtEq1XPbMuuoLOGbLgGKJeIeU4UQ2nRpTlSMBpaYiwx9/UA7EfRvHgg3D5gdFjwq 39rQAibNV6XhDD102gTU6a0AtAATWBu6sRS1nZdLFwijB9N6HszS9FzNelzTXg3BoKcb BB2ujZIaCn1z9TwIN322D2IkdsFq/WZaWyjBKabubU14t7lH6Lnxpll9mW4n/XIcGNnk opZ/qc7866exFQME4zky/J8CAhvw8kN37zLWsBDCijhBv4CrHJW2mDkQG9nc7ay/sR8A fS2LlfwlyD1SuN+UVxOjqDFU2zAhSc8lBkMj/XIcquuZKOke45ZMGW0BuKVDcVsD703+ c8cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LBggX4x+khfJ00VXvvcD5xNoVuTyl4izv5lWBFZj8ds=; b=fGSeBn20XLPihys0GO7nbfDCdyjIlp2+XDO1WiuoL/bRiL8oszXVzqRvX3lTciggTP yokOyrh9Z58j0VBw4dBCUc3yr3JBERKgqdSeT7En/6Bu1OASN9um1fEbxzFsb4o2EyEA 7uc7GRV7m04k2NSsJP7nPH4xHFA2oZWmdkXXNjwTOMNPy+uhBgTKnz+rt+cImUJx8UFm vLm93aLzXQGsJ+zGHtmhOpJcI1r71T04W9wD5ILJtpAi9CZVgX8iHFuqUEtdMc/PaqPN sAjNpWVbR5d5n3ag1wBXZf66ELNySZD1hNoqI+cJdozZkrg+DUSDVrH7M18jSeh4VSVl cmvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CjeICQpZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id co4si7629098plb.363.2019.07.29.12.32.19; Mon, 29 Jul 2019 12:32:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CjeICQpZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729760AbfG2T00 (ORCPT + 99 others); Mon, 29 Jul 2019 15:26:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:38812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728102AbfG2T0Y (ORCPT ); Mon, 29 Jul 2019 15:26:24 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6233520C01; Mon, 29 Jul 2019 19:26:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428383; bh=R52ornbeCZWB1HwdSHHmV6LWHaK0iQcjDXON9+mDX+k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CjeICQpZ70hceBLepzBljv02igRCg6xEkzoIF6XLJLFFT9dBl54Ja3cvl0rR3Tj94 tyREzANr3Ai+Lr4PZByNYibrAPQvRji6O7XAPDdtV8ajF5PUAVr6/UMU5d/tL4r3nI Al2TeeN+jYanVsexxeLXgVg4arKhOgNDr5ywpyX4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leo Yan , Adrian Hunter , Jiri Olsa , Namhyung Kim , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.14 056/293] perf evsel: Make perf_evsel__name() accept a NULL argument Date: Mon, 29 Jul 2019 21:19:07 +0200 Message-Id: <20190729190828.351725502@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit fdbdd7e8580eac9bdafa532746c865644d125e34 ] In which case it simply returns "unknown", like when it can't figure out the evsel->name value. This makes this code more robust and fixes a problem in 'perf trace' where a NULL evsel was being passed to a routine that only used the evsel for printing its name when a invalid syscall id was passed. Reported-by: Leo Yan Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-f30ztaasku3z935cn3ak3h53@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/evsel.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 0cf6f537f980..3ab81e8e079e 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -587,6 +587,9 @@ const char *perf_evsel__name(struct perf_evsel *evsel) { char bf[128]; + if (!evsel) + goto out_unknown; + if (evsel->name) return evsel->name; @@ -623,7 +626,10 @@ const char *perf_evsel__name(struct perf_evsel *evsel) evsel->name = strdup(bf); - return evsel->name ?: "unknown"; + if (evsel->name) + return evsel->name; +out_unknown: + return "unknown"; } const char *perf_evsel__group_name(struct perf_evsel *evsel) -- 2.20.1