public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Wang Nan <wangnan0@huawei.com>
Cc: jolsa@kernel.org, jolsa@redhat.com, adrian.hunter@intel.com,
	mingo@redhat.com, lizefan@huawei.com,
	linux-kernel@vger.kernel.org, pi3orama@163.com
Subject: Re: [PATCH] perf: report: don't call map__kmap if map is NULL.
Date: Wed, 8 Apr 2015 09:56:38 -0300	[thread overview]
Message-ID: <20150408125638.GE26501@kernel.org> (raw)
In-Reply-To: <1428490772-135393-1-git-send-email-wangnan0@huawei.com>

Em Wed, Apr 08, 2015 at 10:59:32AM +0000, Wang Nan escreveu:
> report__warn_kptr_restrict() calls map__kmap(kernel_map) before
> checking kernel_map againest NULL. Which is dangerous, since
> map__kmap() will return a invalid and not NULL address. It will trigger
> a warning message in map__kmap() after patch "perf: kmaps: enforce
> usage of kmaps to protect futher bugs."
> 
> This patch fixes it by adding the missing checking.
> 
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> ---
>  tools/perf/builtin-report.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index b5b2ad4..476cdf7 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -347,7 +347,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
>  static void report__warn_kptr_restrict(const struct report *rep)
>  {
>  	struct map *kernel_map = rep->session->machines.host.vmlinux_maps[MAP__FUNCTION];
> -	struct kmap *kernel_kmap = map__kmap(kernel_map);
> +	struct kmap *kernel_kmap = kernel_map ? map__kmap(kernel_map) : NULL;
>  
>  	if (kernel_map == NULL ||
>  	    (kernel_map->dso->hit &&

Thanks, applied.

  reply	other threads:[~2015-04-08 12:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-08 10:59 [PATCH] perf: report: don't call map__kmap if map is NULL Wang Nan
2015-04-08 12:56 ` Arnaldo Carvalho de Melo [this message]
2015-04-08 15:15 ` [tip:perf/core] perf report: Don't " tip-bot for Wang Nan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150408125638.GE26501@kernel.org \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=jolsa@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=mingo@redhat.com \
    --cc=pi3orama@163.com \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox