Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3936796imm; Mon, 8 Oct 2018 11:59:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV61T6ZTlX7nWsXCmxO5CkjQrz5SRyhTxZXcVz+prNawddNf5oTPkn3prvuQ7uEDgh9cRKmxW X-Received: by 2002:a63:441f:: with SMTP id r31-v6mr22397793pga.60.1539025163743; Mon, 08 Oct 2018 11:59:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539025163; cv=none; d=google.com; s=arc-20160816; b=aCAB1YOihfaerEjvGvVSnnf1UNgPLCmBkuKp+IOxc4dEJZX0JNjsBqyAlTTSkO6N64 RG6bjBkxWpNDc73jh4MlriR48I3rwMkCaKXwk+hJxdoBZnC8vqOmDxyh9+r62Olk2++t UG7F4ZwVJE4JKGSDwH4hBwK37WZkhBAEovmAAmN4/I+8XyiwQuxqEbCrx2zuRFNyqXOu BziioBgO9Ao8BHx5cse25GLdsPZ2+t4pPV2RM4zlSn9uIUP9YbyaKYuKui+GnuYPJyxj EhW/Fykr/fYSKoldJudV5kCp6Mib9PBAPgomM4C5+MZuAQf5M9CXR5l+obwwXnv03CfF V+1Q== 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=+9j7/5O4QJa+AlVnrdMLAs1dnpY4UdBZIT6sGpSR0ek=; b=uysTEjIBcVXyDGkYtX0Rujh5litVEF1R7aQcg63p+mVNBMlY0uV+KSovFUW38W6LBI C2/fUp0Y6kWHKZykZeyEUnsZdQeCZCJ5lKpCXZFkIftfJEdeeFsnJ0W3BraQcGEL6mzQ gzNlWyivE+yTHN8/Pvxa4TkteTXqlgY3CTovVEbJ5pMdCa6q1XY///WCQxRUoqn3Moxf D7sRv6snU+0lmZ3gZMnV2aRjwTieN+5LWojHXwIt+UhIX7XpnQtSTGqw9CyBavt9ie4q oeq5FURFeExDZZ2HDF4qOfUxME66uzg7BminsXg0zHYwUQOx9j0FuNGJbo+hMKVJQXzj AV1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FreNHLrY; 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 o24-v6si14476464pgv.242.2018.10.08.11.59.08; Mon, 08 Oct 2018 11:59:23 -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=FreNHLrY; 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 S1732246AbeJICEM (ORCPT + 99 others); Mon, 8 Oct 2018 22:04:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:53878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729987AbeJICEM (ORCPT ); Mon, 8 Oct 2018 22:04:12 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (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 3144E20645; Mon, 8 Oct 2018 18:51:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024664; bh=1pOijNMTkWSkhHAmJEECdXCfKj0VQcKtia8kS/bcvVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FreNHLrYyF3nvNjCCMNydWroI2061x2rE5oIeNM+EhyrxueQpnUHmedu9UVr4XhkL YKTKwGXQsmM+LPFodgtAAaoMkWCHqZJRLztEnqOCDzzeeZ7x2wD/9LUwTIKEAUl7HP L8qTULbYo6W9sn92XgJ0/ygeyvywDbqzqziqsuII= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hisao Tanabe , Namhyung Kim , Jiri Olsa , Wang Nan , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.18 090/168] perf evsel: Fix potential null pointer dereference in perf_evsel__new_idx() Date: Mon, 8 Oct 2018 20:31:10 +0200 Message-Id: <20181008175623.486256015@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hisao Tanabe [ Upstream commit fd8d2702791a970c751f8b526a17d8e725a05b46 ] If evsel is NULL, we should return NULL to avoid a NULL pointer dereference a bit later in the code. Signed-off-by: Hisao Tanabe Acked-by: Namhyung Kim Cc: Jiri Olsa Cc: Wang Nan Fixes: 03e0a7df3efd ("perf tools: Introduce bpf-output event") LPU-Reference: 20180824154556.23428-1-xtanabe@gmail.com Link: https://lkml.kernel.org/n/tip-e5plzjhx6595a5yjaf22jss3@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/evsel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -251,8 +251,9 @@ struct perf_evsel *perf_evsel__new_idx(s { struct perf_evsel *evsel = zalloc(perf_evsel__object.size); - if (evsel != NULL) - perf_evsel__init(evsel, attr, idx); + if (!evsel) + return NULL; + perf_evsel__init(evsel, attr, idx); if (perf_evsel__is_bpf_output(evsel)) { evsel->attr.sample_type |= (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME |