Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1106716ybi; Fri, 2 Aug 2019 09:24:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqznlsK2DfD6PA8qWqxdjLG/WytziRGbpqsDjG31HUp/ZSPdrFUvvsazDhXYTRRQbWidC8Je X-Received: by 2002:a17:902:2f84:: with SMTP id t4mr128931220plb.57.1564763072206; Fri, 02 Aug 2019 09:24:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564763072; cv=none; d=google.com; s=arc-20160816; b=XzDd1QL+w9HNPdtE0MXOkEzyboLSrTVcWzMKA6pdqbj8Q40tjpgwXTcJCKbLmaNnBW EgLhbkLTkj+aAM0V19EDu4Rs8YA0Phb3OIQobHqL/lHxcY33FpxPU+14Rk+oHqjxXGTh 6kAllibI85Pd9e82LE76aew71DkPTZ7QzEYevdxy/EXR9bHU0mTx0rkIYu2fBgcsK0+z waeTjhtOWKFy5JqDztOEeAPMck/MBpoANthx4oHXBaGhf375sI0bxLmWHKhLWv4WGOYy Rw5/FcgS5q7Ov3idqGxOdQrBwZkBmPFfalUMeUDlTwCSO6YQ4lr/12L8ruzSrpt9jHOv Bd/g== 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=ILqy3HqbJ7V5aHPDsaAt7isHbfkdoEvZ+SnsY3ZKg48=; b=pyJv0rB89JoNklSk9XQIAb6wZC4RWoiBW3c0S/GkzTY5epcIkSkOf2SqX91XutXWRe V/Q7r2X3Qduo4azXDk9FkTWFeovPLlRT6eNYffrJFNvZJ7texpNcYBBRau705kz6XlwA NVeTeV7w+XySiVhgMxkA6KiqLokZLnI26O1PxRPmrmGbsRBA39b2e71Y1spyAsOpvemx AW5ukhsWGlvhHq1kLnyyEfY+YhjbxVMdqvLERdeWm+WrSZNxZKX5y7VJtevUujpEbRrS syKMaFM459jgPiQw7GHUxu20gYLapSpEm4ghHIgLaR53pIV8FdlaqGAM+lv9xb0/7KTR YHzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mz02eiE4; 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 x184si26209643pfb.24.2019.08.02.09.24.17; Fri, 02 Aug 2019 09:24:32 -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=mz02eiE4; 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 S2404898AbfHBJls (ORCPT + 99 others); Fri, 2 Aug 2019 05:41:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:43592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404889AbfHBJlq (ORCPT ); Fri, 2 Aug 2019 05:41:46 -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 D1A6C20B7C; Fri, 2 Aug 2019 09:41:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564738905; bh=bCes74bOaCPXhN5SywgjIuZE0j47KO/j4UYNediCAvc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mz02eiE4GRTu0EUIcMkwo7eTjFD/qeZM0oG1Ny2Cfo+fNEGJ+aRp4EZhq1okTeEWY OhOFKRvg7cuNfI8lRzQQCskAM/Ex85NMzsDO3Wm6bntAqLkS4YipOYpTqMTEqG58Yl zrV4Fs3S3sU12WGVSn5hfCv5qXUaM10BiX8SXWCo= 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.9 041/223] perf evsel: Make perf_evsel__name() accept a NULL argument Date: Fri, 2 Aug 2019 11:34:26 +0200 Message-Id: <20190802092241.647599000@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092238.692035242@linuxfoundation.org> References: <20190802092238.692035242@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 a62f79558146..758d0108c5a5 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -558,6 +558,9 @@ const char *perf_evsel__name(struct perf_evsel *evsel) { char bf[128]; + if (!evsel) + goto out_unknown; + if (evsel->name) return evsel->name; @@ -594,7 +597,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