From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7013031576C; Mon, 13 Oct 2025 14:54:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367266; cv=none; b=CfVvynNmhiupMPVlj6SXe/SnLkk0M+OTaGQJnLwdeI5/Jib4MfceoioupgL6t+Wvu3Uqxr5RfMpGm9GOQxKpAhm+dLruouQyJFtys1LzPbgUs3f5c3D0UP/wQ+W15LPSXzMByRXqu1V37ZBbCPsXS6CnoAdPVTVCYkL7prIy4+c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760367266; c=relaxed/simple; bh=wz+rbvpanliI/udJNjTaftv1SgWFr1V94rpUHtL5aNo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lwDGFCb9gZ2Q+hG5nD3bXN2MUcvek/LxC8J3VkElbys0k4LGPza/5UTj1IfY6AK/uhu0vtAie52ZFbEeok1g7Mr5or11IKSFW4KVBXz8Lof9EUpycKEfOsNbM3hxfSfrBXXJc3aNGH4g1PkLeZmEigIohWcZ/TqCFrE/ym7tAH8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IRyIlZSL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="IRyIlZSL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECA4EC4CEFE; Mon, 13 Oct 2025 14:54:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1760367266; bh=wz+rbvpanliI/udJNjTaftv1SgWFr1V94rpUHtL5aNo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IRyIlZSLAhy7QdOgIg9XU5auOIiayfbALFABq6hjnLntS3ftSxl47L7lORjsWuyc2 fhkzOrjuBsIlQPSeMTrgAR+33XZc82GRwctuX+g+O2UZAcUA0NsJOmGH7gA3XuvUae 6IBP6B78RjQdhPMEZ2WlMR1DJF8wIWibCeydMlwU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tamas Zsoldos , Leo Yan , James Clark , Suzuki K Poulose , Sasha Levin Subject: [PATCH 6.1 149/196] coresight: trbe: Return NULL pointer for allocation failures Date: Mon, 13 Oct 2025 16:45:22 +0200 Message-ID: <20251013144320.087578951@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251013144314.549284796@linuxfoundation.org> References: <20251013144314.549284796@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Leo Yan [ Upstream commit 8a55c161f7f9c1aa1c70611b39830d51c83ef36d ] When the TRBE driver fails to allocate a buffer, it currently returns the error code "-ENOMEM". However, the caller etm_setup_aux() only checks for a NULL pointer, so it misses the error. As a result, the driver continues and eventually causes a kernel panic. Fix this by returning a NULL pointer from arm_trbe_alloc_buffer() on allocation failures. This allows that the callers can properly handle the failure. Fixes: 3fbf7f011f24 ("coresight: sink: Add TRBE driver") Reported-by: Tamas Zsoldos Signed-off-by: Leo Yan Reviewed-by: James Clark Signed-off-by: Suzuki K Poulose Link: https://lore.kernel.org/r/20250904-cs_etm_auxsetup_fix_error_handling-v2-1-a502d0bafb95@arm.com Signed-off-by: Sasha Levin --- drivers/hwtracing/coresight/coresight-trbe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c index bc6e247443e80..a584e5e83fb57 100644 --- a/drivers/hwtracing/coresight/coresight-trbe.c +++ b/drivers/hwtracing/coresight/coresight-trbe.c @@ -743,12 +743,12 @@ static void *arm_trbe_alloc_buffer(struct coresight_device *csdev, buf = kzalloc_node(sizeof(*buf), GFP_KERNEL, trbe_alloc_node(event)); if (!buf) - return ERR_PTR(-ENOMEM); + return NULL; pglist = kcalloc(nr_pages, sizeof(*pglist), GFP_KERNEL); if (!pglist) { kfree(buf); - return ERR_PTR(-ENOMEM); + return NULL; } for (i = 0; i < nr_pages; i++) @@ -758,7 +758,7 @@ static void *arm_trbe_alloc_buffer(struct coresight_device *csdev, if (!buf->trbe_base) { kfree(pglist); kfree(buf); - return ERR_PTR(-ENOMEM); + return NULL; } buf->trbe_limit = buf->trbe_base + nr_pages * PAGE_SIZE; buf->trbe_write = buf->trbe_base; -- 2.51.0