From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752020AbcFVG6U (ORCPT ); Wed, 22 Jun 2016 02:58:20 -0400 Received: from szxga05-in.huawei.com ([58.251.152.179]:55042 "EHLO szxga05-in.huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751831AbcFVG6F (ORCPT ); Wed, 22 Jun 2016 02:58:05 -0400 From: He Kuang To: , , , , , , , , , , , , , , , , , CC: Subject: [PATCH 5/5] perf tools: Fix NULL pointer deference when vdso not found Date: Wed, 22 Jun 2016 06:57:06 +0000 Message-ID: <1466578626-92406-6-git-send-email-hekuang@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1466578626-92406-1-git-send-email-hekuang@huawei.com> References: <1466578626-92406-1-git-send-email-hekuang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.193.250] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090203.576A36D5.007F,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: dac830df3ee51f8808e8edd94eb7046c Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We should check if 'dso' is a null pointer before passing it to the function dso__type(), otherwise a segfault will be raised in dso__data_get_fd(). In function machine__find_vdso(), the return value checking of 'dso' is missed and this patch fixes this issue. Signed-off-by: He Kuang --- tools/perf/util/vdso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c index 8f81c41..7bdcad4 100644 --- a/tools/perf/util/vdso.c +++ b/tools/perf/util/vdso.c @@ -296,7 +296,7 @@ static struct dso *machine__find_vdso(struct machine *machine, if (!dso) { dso = __dsos__find(&machine->dsos, DSO__NAME_VDSO, true); - if (dso_type != dso__type(dso, machine)) + if (dso && dso_type != dso__type(dso, machine)) dso = NULL; } break; -- 1.8.5.2