Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2649683imj; Mon, 11 Feb 2019 06:28:01 -0800 (PST) X-Google-Smtp-Source: AHgI3IZhjCfmLDZtSRfqJJDBe75X54un3ZDa2aiqREVi6BAjhPcrW1ApUiKKtE03D9K74Jx0noTR X-Received: by 2002:a63:da14:: with SMTP id c20mr32533424pgh.233.1549895281369; Mon, 11 Feb 2019 06:28:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895281; cv=none; d=google.com; s=arc-20160816; b=PyjBgNsVgwjXI07070fFJih4iZ1NIFOVT3KUFtRCCeExnscHT2QUgr9BteL2Fl2fBJ L6Z6pKUpIELh9QwAHSjmqz0P8wesreh/93r9eaY2RDVggF7FksNksxioBLE9w6tZn2Ac sdKaTMyUUdtQiLoTBUL8TTKiV0Dz2HJf86eyiEsFmuI6gZaoJ4ovmesz2uxdl8+cCjyj winww1oOzDHrkq5lk+U9C0XsSNXDcMGkBJyJ2yf4XE7kQPmCtD3/IbPLHBrcmRBV1cH7 0/HI3qYIUHb8JsjucPsWSUM5ZCW4Q0+iKGX+SO3XGyACer9x8YdxKTrPtBJvVuL4A/YX LvZw== 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=p6NNwNjJFNwb4/fFlP3AFEZHVJzJhPPXjK1Gh5rLaFc=; b=PuKLXOcb8qW/fF71G7+kk/gUELIxxHrJir90wdG0kfVChH7QET7Pf0dONgsvghnY/5 RdeZroRsCtrEfbF2ezNJWjCQqH+d081eLEsUaaeWOLPWbNB3y9iMO3nHqAP3HRt1ow0h PwWAkJBlqG9CCGIuEXlNyub3jK0fHQ92oa82mvR0B0mB39dS9Gk6rqMu4F/pB7AJ9cqG otL7kuOX2VqR/DEtWCy6fCB/CSgWbVocdy83iE+6HXps6V1z32JGTyH78rEWhQ1PfYEw O5Juz+tmF+4t3WRW0kWtrpB6kYYg9SvN3/H7rjONRlcoTRMkl5n1owYljNRc3ifdr5Iu mPVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Icu0s4wM; 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 i186si4988404pfb.108.2019.02.11.06.27.45; Mon, 11 Feb 2019 06:28:01 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Icu0s4wM; 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 S1729305AbfBKOY7 (ORCPT + 99 others); Mon, 11 Feb 2019 09:24:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:58262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726074AbfBKOY5 (ORCPT ); Mon, 11 Feb 2019 09:24:57 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 1974620821; Mon, 11 Feb 2019 14:24:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895096; bh=N4y+9pC3UG2d+NHw9Jl5js2xUnc1xnoRi0pyyDxKBn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Icu0s4wMJyFr2SUbmRlxgPpmnsFnVWOw4MeHjzO0Pdkg39pKNTU9h3ckFVAbM9Jdd kr8YQ1lxcxeQBx1PbUiL82cNhHyT/EBhty1QyOfSn2Qwc20sp85CX1/J6Exm1dNLIS jjXtJbzyH+i+mK6Rg4OVE5BRaY9JDFFG37bduFHY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Nicholas Mc Guire , Will Deacon , Sasha Levin Subject: [PATCH 4.20 091/352] perf: arm_spe: handle devm_kasprintf() failure Date: Mon, 11 Feb 2019 15:15:18 +0100 Message-Id: <20190211141851.695251746@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 754a58db6a556e6e5f5e32f3e84e7d67b5bf9c8e ] devm_kasprintf() may return NULL on failure of internal allocation thus the assignment to 'name' is not safe if unchecked. If NULL is passed in for name then perf_pmu_register() would not fail but rather silently jump to skip_type which is not the intent here. As perf_pmu_register() may also return -ENOMEM returning -ENOMEM in the (unlikely) failure case of devm_kasprintf() should be fine here as well. Acked-by: Mark Rutland Fixes: d5d9696b0380 ("drivers/perf: Add support for ARMv8.2 Statistical Profiling Extension") Signed-off-by: Nicholas Mc Guire [will: reworded error message] Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- drivers/perf/arm_spe_pmu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index 54ec278d2fc4..e1a77b2de78a 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -927,6 +927,11 @@ static int arm_spe_pmu_perf_init(struct arm_spe_pmu *spe_pmu) idx = atomic_inc_return(&pmu_idx); name = devm_kasprintf(dev, GFP_KERNEL, "%s_%d", PMUNAME, idx); + if (!name) { + dev_err(dev, "failed to allocate name for pmu %d\n", idx); + return -ENOMEM; + } + return perf_pmu_register(&spe_pmu->pmu, name, -1); } -- 2.19.1