Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3707613imu; Mon, 28 Jan 2019 09:22:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN7gP7aYKiTmmIpq1QNBzFJNSnCPd0oVx60UaFFpop+ewB6xPnFaqeswUsi/wejvGb18Mioh X-Received: by 2002:a17:902:b112:: with SMTP id q18mr22657316plr.255.1548696175680; Mon, 28 Jan 2019 09:22:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548696175; cv=none; d=google.com; s=arc-20160816; b=oUAEJNdIhE4Ng0CFd4paABkESM9FvZ/jYppDJto5zGx2jAzPWhlhSIvZ8Xs2vU4h99 wjMboue78Lq7yqz0UAVI8pJsFOPpvZJzfRHNE/D1L1aZpf8VnuDBv+N0PwGoGsG64HWr 7c1mVculQ57JM+HTsq+vcMQl+FQp+huAyWNfe/lTJbKeV4aUJJzJkz2CV+z/GKxTIqAc W7oIMYsK8Y68NEVXOOLLjtL3qIVYpGpL1icoEFUTBtz9PBpLM1DMrewaEUt/PB2ThdTm UxhFVvDAw3yVwZNTPehCyz6n32i/2UtHYHIubUE45KrXmWnTgRnKDrpo9OUy5MVD3p2Y Fh6A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8NCuuGx1z4REXxrWIaycwk/OmOxd3Jz2v2f+bxhm7XU=; b=bmiktw98LCFh+y/v0baj+3hL4MVPDuAL0cIERd3VIkP8EeZ1aSMOlgnjvRrTWdXmUa WCdR/R69t91eLlh/QNQwQ80cNYFGaA4eXaW9iKv1qRaTXE7H1wRTrbcxieyntfLLCKUf ymALnvG+vncliJ6xr68Z4YpIlfPpZXgFQ+2/LHdV/2KpR6Hj6RrYmUNpOkbhfqmkRdPz IrvD52PG+oYbk2rPE/y/RUD+Pbs+bOSSWwq0aO9XacRky7gyjxAMHab+h8x14YXYUzpQ kAQVJc3dT971sbAebE+CqkxwdGgkXycrSUrFgSUyvdkoaHKrpf9KDQay2iHaqzKCev2Q jtow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1Muvf9BE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l13si32301855pgi.46.2019.01.28.09.22.40; Mon, 28 Jan 2019 09:22:55 -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=1Muvf9BE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731629AbfA1RWS (ORCPT + 99 others); Mon, 28 Jan 2019 12:22:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:48774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731057AbfA1QD0 (ORCPT ); Mon, 28 Jan 2019 11:03:26 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EA4042082E; Mon, 28 Jan 2019 16:03:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691406; bh=LWe5T3FnuLi8FDdx6034raqSmyFhP7x+OGZF8mWDHJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1Muvf9BEytUX6RfOYaOSmf1tVXqCPzZ36A5+tlBVaLcqjwkUSZgZKZcEMenv7cgkB 567VOz5ed1thFv7GUEzYBByhYiZGR2V0mR/YK4qyVoQDPihG6oaSCo9xjAr6629srw bN2BaLHNU4RQoWyca97yLO3P2upwY3SNpXkeOdU4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nicholas Mc Guire , Will Deacon , Sasha Levin Subject: [PATCH AUTOSEL 4.19 084/258] perf: arm_spe: handle devm_kasprintf() failure Date: Mon, 28 Jan 2019 10:56:30 -0500 Message-Id: <20190128155924.51521-84-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nicholas Mc Guire [ 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