Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9985805ybi; Wed, 24 Jul 2019 13:34:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwx2fRuVR1tbF++yEm5meyrUqypxTEN6Zqb+XM0008pOVwfFhUgoxrVeqVGVcpgsYvubO2y X-Received: by 2002:a17:90a:2486:: with SMTP id i6mr88480286pje.125.1564000480808; Wed, 24 Jul 2019 13:34:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564000480; cv=none; d=google.com; s=arc-20160816; b=OJd3yZl+L9ah1imLFyvYsGo/4wfJXXj7foKp3CRUG7lhxtAfMCaDl048h9KPbuRjkO DzQCieMqE/FuVxj1hnnEcob7Wq2Z3M/1l57q8C+3ZN2IpRdTdt8mOCySv73i2WvKtvkm GKMXGSryMYQQZ9wEgIiOXxVOWDEcs1TNMqfsgJKOYo9x8MBQAYbhoJGWZ73UCd8cf6Fz pHPJD+ADnmz+/VAiwLRZU4sKeYpbU2/RQVKwC4cbxRSr0a6djUMGnqkpNe1llQxHC8IP 2DMngSpIh/suaUpJ4dqvvUVq1OXTeYc/p8p03BRCbr4W5I28em+65flQnMnMXPriZVG1 N1kQ== 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=oIp7LaaCTyQ+HYXRaMo0YqKqnme+xGHhbhEQ2yHy4ZI=; b=yrpf+Ls07x0kjevpjCfdBHs5faNVdbWUguT7smXx3X7/6CwOiMHBcaj5jJEn+i0V1z QMeTM4eoXmonoqWbiVJwCCHBDoNxZJm0WECbHAxMgaczCG3q3YoEWiaiV12v/C7VMyPj iWcVcBhs5h5YKrEiZSfYtWNHC6peRGC6XN0vDagXkiF7ydKNksnJpE+ki9N5pvOlkk5q 0XcD8fp551WDzYfmMJ/A8mCN62BYR19V0PRy1w5EhH3D0e+ElRnf5+6CggRIXMzIbtj8 KK7AjiJ8VCtdD44zxBQluWIrcJyVQ8TzHLIOjmErFTZOiYmOzlgiShBXNmaLhN0OXfHe h8ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xiE4Oanv; 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 w188si15362729pfd.283.2019.07.24.13.34.26; Wed, 24 Jul 2019 13:34:40 -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=xiE4Oanv; 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 S2388460AbfGXUdE (ORCPT + 99 others); Wed, 24 Jul 2019 16:33:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:46462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727408AbfGXT2R (ORCPT ); Wed, 24 Jul 2019 15:28:17 -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 7D280229F3; Wed, 24 Jul 2019 19:28:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996497; bh=z5zbDP/5A8gvnmdZIICf7EPPYgwoz6x1I01CY1sSJgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xiE4Oanvojv3uqD1sO7yEnKuWIbjpRXslr3+kWrDmIqYxkBr6T9x6RiQYs6eV9SVl 0sX3pWb734nseUt+5FhlIkLwG7r22IRbcNHPuvGIdU6s8LEvSiSqO5c6w2cM4RdIlB vC25xhJrnZxGFSdkMopvduUqj7AJW65vCQpD+ERs= 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 5.2 115/413] perf evsel: Make perf_evsel__name() accept a NULL argument Date: Wed, 24 Jul 2019 21:16:46 +0200 Message-Id: <20190724191743.538219473@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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 4a5947625c5c..2c46f9aa416c 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -589,6 +589,9 @@ const char *perf_evsel__name(struct perf_evsel *evsel) { char bf[128]; + if (!evsel) + goto out_unknown; + if (evsel->name) return evsel->name; @@ -628,7 +631,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