Received: by 10.223.148.5 with SMTP id 5csp6040514wrq; Wed, 17 Jan 2018 08:40:24 -0800 (PST) X-Google-Smtp-Source: ACJfBouWd+uRzj3CfNwb217HEu88NHLyVbySe+ojNGymV2eDQDWZU43Ov9hVfkOG1BiN6xe/zmnX X-Received: by 10.99.65.7 with SMTP id o7mr34712707pga.238.1516207224050; Wed, 17 Jan 2018 08:40:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516207224; cv=none; d=google.com; s=arc-20160816; b=0dMQECyGPwBtToEFML8IT4yTNoA5rd5yO2pBjmrHTf5qi/Uq6pC154z2HnXJoSU3bK p2+N6ADEKybM35KYjKlLd/45fX/kD+QmoWutxtPUJkf6x2+7i9mPJQf1CjB2npJAkJza UatOhxGSMmQ9MrAeqRyHL6H0EZZn8sLela8PE/SBZn6Uo9OdckJ1WQzN2wINkALYsR3T m1//8YGeGWAjc025uU7jr+lTeHRFEzrvc+X/B5Kuv5im1upm6TIDLqH2aSHqo5F2VfBj agdzDZwPvsQadrtJlhfSEzwz7eZgbyw40FKYOlWMFBBRkzZriVqhXOrHmqAsw/zvBCQ+ QmRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=t8bF6ORGWwVdvIWCJFLCAwSWqfGqDCrnSPVOB3s72sc=; b=pCQM54hlw9FmKjplzRq2hnRXwiczZwcw2P243RwkT3nL5rSee+CFPB+g8yhsGgZRpK yaRu6Rtr3guT0x0x8vSsWypjBEuCx13oF6q57C2Zne+rQj2lo8xvi4Gnx70IgiVs/S4M iABMBp/StDjTKOecLIvvxOK2YH4Vpfd9Vn+AQQsTHDZefX60H937wkUZnZJbfbDdgbyR 936+8FRsIspHxPG4iViBTQcKMjmbaJkjI03Lfyf1yFg8bXd9WZSAyp1iv3IbTEycXGTb dqM/PPnWoTHBB/nyiZhNdKefv5gzYedqNH5Sjij34Acv+xtvbAIXyGKhd2MP/vOVi//i OQ+A== ARC-Authentication-Results: i=1; mx.google.com; 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 f64si4828051plf.473.2018.01.17.08.40.09; Wed, 17 Jan 2018 08:40:24 -0800 (PST) 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; 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 S932082AbeAQQji (ORCPT + 99 others); Wed, 17 Jan 2018 11:39:38 -0500 Received: from terminus.zytor.com ([65.50.211.136]:42609 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754185AbeAQQje (ORCPT ); Wed, 17 Jan 2018 11:39:34 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w0HGcMh3002939; Wed, 17 Jan 2018 08:38:22 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w0HGcLnV002935; Wed, 17 Jan 2018 08:38:21 -0800 Date: Wed, 17 Jan 2018 08:38:21 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Thomas Richter Message-ID: Cc: hpa@zytor.com, schwidefsky@de.ibm.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, mingo@kernel.org, acme@redhat.com, brueckner@linux.vnet.ibm.com, heiko.carstens@de.ibm.com, tmricht@linux.vnet.ibm.com Reply-To: heiko.carstens@de.ibm.com, tmricht@linux.vnet.ibm.com, brueckner@linux.vnet.ibm.com, mingo@kernel.org, acme@redhat.com, schwidefsky@de.ibm.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, hpa@zytor.com In-Reply-To: <20180117131611.34319-1-tmricht@linux.vnet.ibm.com> References: <20180117131611.34319-1-tmricht@linux.vnet.ibm.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf record: Fix failed memory allocation for get_cpuid_str Git-Commit-ID: 81fccd6ca507d3b2012eaf1edeb9b1dbf4bd22db X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 81fccd6ca507d3b2012eaf1edeb9b1dbf4bd22db Gitweb: https://git.kernel.org/tip/81fccd6ca507d3b2012eaf1edeb9b1dbf4bd22db Author: Thomas Richter AuthorDate: Wed, 17 Jan 2018 14:16:11 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 17 Jan 2018 10:31:25 -0300 perf record: Fix failed memory allocation for get_cpuid_str In x86 architecture dependend part function get_cpuid_str() mallocs a 128 byte buffer, but does not check if the memory allocation succeeded or not. When the memory allocation fails, function __get_cpuid() is called with first parameter being a NULL pointer. However this function references its first parameter and operates on a NULL pointer which might cause core dumps. Signed-off-by: Thomas Richter Cc: Heiko Carstens Cc: Hendrik Brueckner Cc: Martin Schwidefsky Link: http://lkml.kernel.org/r/20180117131611.34319-1-tmricht@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/x86/util/header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/arch/x86/util/header.c b/tools/perf/arch/x86/util/header.c index b626d2b..fb0d71a 100644 --- a/tools/perf/arch/x86/util/header.c +++ b/tools/perf/arch/x86/util/header.c @@ -70,7 +70,7 @@ get_cpuid_str(struct perf_pmu *pmu __maybe_unused) { char *buf = malloc(128); - if (__get_cpuid(buf, 128, "%s-%u-%X$") < 0) { + if (buf && __get_cpuid(buf, 128, "%s-%u-%X$") < 0) { free(buf); return NULL; }