From nobody Sat Nov 30 05:35:50 2024 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47B3F183CA6 for ; Wed, 11 Sep 2024 09:07:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726045636; cv=none; b=fhJkYhNK8Ps8nHd9iMMJDemn6SKd/aUpbWwsPn4CsTfGWyc8ga9hTyvJNooyYSeEZTGxIR446ZkXbc1JdbHruCgVsXqY51DoIFCqP/enwPVJSdTj8jQr6pBxucxvS4Uz+3/D4hz4OxJyTgB3L4chGHCTb3KXg1OCqZJoGDcAIYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726045636; c=relaxed/simple; bh=esOhHdSW3GYG4bDgOTaZ8aIxvJkfujR+IQ+ftKEU+as=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lPmACfyZ4VXtQoiCB2JN6bbHbucAV9gsXSMvP7XqPxRLWWy3f412/zikjmJUMGgkNIpNNY+rDsFFNk++dBImL5JEGlTOYfYSY3vVjhSeS1Wtqu5umq9E027VwSklhnNyihkalMXcK2H3uVUTH7I7jUi8NdVVDgxvzy5He3dt5IA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=fEnJWyf8; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="fEnJWyf8" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-374ca65cafdso4100027f8f.2 for ; Wed, 11 Sep 2024 02:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1726045633; x=1726650433; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=05zG+KaVF69ctZg0Bv54vLcj+DDRJ4oFWnu1GNWBi1k=; b=fEnJWyf8y1zc96DGnM0UomUa7rAHfrmGWiUUpRjmjc4mpHWb3Q6XTM7twSORpnyZ7N KS3nBIECE39z7du6wqpUrgrdypkT7qaFMNLrS36gnrYNtfwhWPeUS6Mll+31gTCx/ZoI t6zSFq9eycb/Wm/kfTK8reterixPy3Htvj5RbwurcievshFnM6YMro8rYewWMoCwghHv VzLjxBBlOW2dFqeEP5Z2teS2ybbi/sFWubXEXfZr2hWY+419eNZ6K4Ej9lxoOrGbzlg5 oXpQYIIQDWjTpeq1FL/plhRFwmJ3LmAnWLwb6uCjwqOBkducSkC2lTrvEhjFzTZTZ8rj osoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726045633; x=1726650433; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=05zG+KaVF69ctZg0Bv54vLcj+DDRJ4oFWnu1GNWBi1k=; b=P+KW3qrq8K8G8ctgXRBaTg8Kh1T1fKOaVp77h6jZvTEbJurw2fHPFbjIKqgYVC3qGF nrAV03ScIp1rsBPP8szNWEWNrBO2ycWkOsmCAPBuVunNKOlNyrcoaSZEF+92YLh+VVYK w5dZ8pJaJ9r9EPAiIjvWQw25enSX2xLNJwAAZKMTLASs0iKYhvoCp+JimK1BpKoAbj51 Rgii6/0xWB8GCc1X3rQ5OZsR25yDdZ7FQiOB8Qx4mwYKjelhfZ6Pnt0lr4abSDXGMXHo eSV1nZM3JDSO5Ya1Oj6CxyRq4+RFpdadxjcafP1hRQjjubAG6gqxqmD65HP1G0FZga6X gpGA== X-Forwarded-Encrypted: i=1; AJvYcCUXZFQ4DUIk06ZoY0ai8hZAr22Y0TCNPtUi8gkYRQslaOERDeH7K+l+VSwWDhSrorETuiZWm3F4HfYgeT8=@vger.kernel.org X-Gm-Message-State: AOJu0YxJmbWC3x2KuQ60x0fMUOavKWutWHuuJVO0QHal6xuCw4IHWaCE pxTUMLYK7mscPUb4f+ypACoMWcua/2hn8B4fDZYoCMMNo/wBgELuOllgmtmDN3s= X-Google-Smtp-Source: AGHT+IF+Y80/Fy9Xw33GsPPPORhNGEe/YCmSlFhWcJOkn1iXNoQasv82Gka4D9L4IpozUSlX+6lRCA== X-Received: by 2002:a5d:4584:0:b0:374:c95e:1636 with SMTP id ffacd0b85a97d-378949f7c06mr8453359f8f.21.1726045633317; Wed, 11 Sep 2024 02:07:13 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:dc:7e00:5389:6cf0:60c4:3842]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37895649b88sm11029201f8f.6.2024.09.11.02.07.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 02:07:12 -0700 (PDT) From: Bartosz Golaszewski Date: Wed, 11 Sep 2024 11:07:03 +0200 Subject: [PATCH v2 1/2] firmware: qcom: scm: fix a NULL-pointer dereference Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240911-tzmem-null-ptr-v2-1-7c61b1a1b463@linaro.org> References: <20240911-tzmem-null-ptr-v2-0-7c61b1a1b463@linaro.org> In-Reply-To: <20240911-tzmem-null-ptr-v2-0-7c61b1a1b463@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Andrew Halaney , Elliot Berman , Dmitry Baryshkov , Rudraksha Gupta , "Linux regression tracking (Thorsten Leemhuis)" Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1161; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=mGZy4q/oW8UzoOdspQ2PE/4+hSe74fQuun548/q4F44=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBm4V28JZ/VEfTnaD7nNBoB3frcKuGLB9ARP4bWY bWaYUI16HGJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZuFdvAAKCRARpy6gFHHX cpWmD/4mJG0x9Wtf91kBXu54OS8ukIUVtB3Olonnh6WlFUS6GbattKh4M/Zgmi0rn2SiTCLHUPu /hijbeXzEVURratLEVqcPpCEOIvVr4g8oR0LYpbvIURqHhPrpBt8de9PQ6y2WoD6NpeN0eED/vP L3RK3UH2yddZJA7yikXmiT7lovvM0/N7TZppP8bBXqq+oxV23yaB9QyKFfYmctDa7FZQkI8CGpt IMitrLQz4TFn00+pmx2/07vIkQu0wL2+6026OxHDTAriQx+SLkKSDjaEA6G+SADjQrwjNylUrez LowDn4rV3FAPfqAzAw2Rwgfpu8tHGPkHRjw6+TWIuaA/qFNMdEuIg8aIntBqz7VDFouw3NN+7l+ 1sdY9T5ajf6sgUTPm8mm9sFDyKFjMT9s/MgtijCj0+5D4KxaBSsT/kFN/wXKaflvT9Itb++Jz1W nO710wrpUQknR8xNg9fjpz/RhBc5cjgcK0w1TNxlMGLFT8oQHySz7H5OUyMzkCQR1TLY1IiCD+o m4U5b7aQSE4Gqr8httoq9f7zit3nit/xVS8Znvq+6YgCr0bTLkd9Ze8qGsEYj0+HG0+2obs8JBb MkGME+1TTmQirZSG3DsjLUyCxAfOLbHbOE0Oficm1h9sDeZ6zx/sBO+y1ElwJtprqYWZ6RAFdLZ wVAxtssmyqJmj5Q== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski Some SCM calls can be invoked with __scm being NULL (the driver may not have been and will not be probed as there's no SCM entry in device-tree). Make sure we don't dereference a NULL pointer. Fixes: 449d0d84bcd8 ("firmware: qcom: scm: smc: switch to using the SCM all= ocator") Reported-by: Rudraksha Gupta Closes: https://lore.kernel.org/lkml/692cfe9a-8c05-4ce4-813e-82b3f310019a@g= mail.com/ Reviewed-by: Konrad Dybcio Tested-by: Rudraksha Gupta Signed-off-by: Bartosz Golaszewski Reviewed-by: Dmitry Baryshkov Reviewed-by: Stephan Gerhold --- drivers/firmware/qcom/qcom_scm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_= scm.c index 10986cb11ec0..8bac4915c211 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -216,7 +216,7 @@ static DEFINE_SPINLOCK(scm_query_lock); =20 struct qcom_tzmem_pool *qcom_scm_get_tzmem_pool(void) { - return __scm->mempool; + return __scm ? __scm->mempool : NULL; } =20 static enum qcom_scm_convention __get_convention(void) --=20 2.43.0 From nobody Sat Nov 30 05:35:50 2024 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C04B185958 for ; Wed, 11 Sep 2024 09:07:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726045641; cv=none; b=eAtZhoMxenEaJwPnj4Bx/+kzXxozXnQCxM7olEt1dmQ2nvNnTdMLDoOAeaqangH8KFyV57pnlwqnx2R3oZ+OLaHfMkuirednE4DoMQplQ1ryDRbiD+G1z3HhjRC4I5v53TARk2CksY7OKl7I5sUw781D3wvv/v/uvIl2KS18mOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726045641; c=relaxed/simple; bh=fsAgJwHDEr+KSiZVY7zNR69LYpXgTK/JWvq+XG0/C90=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BRM0VocU3x7FqWXl5GHa1UjFtiNfmJ9SVGwq00LYzeLeWwf3NvbHVP9q9hwyJL858NvOfS1Ve2rAR4yv6+jsISSouxVWRCpZcMbtNMK7cEn4VvejviBYKKgJlvhWfZGt/VArOEFJrQtbcj7KLyanUCwqh6EC8gb3ONXCwngol0c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=Bcyec3xS; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="Bcyec3xS" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-374d29ad870so4041678f8f.3 for ; Wed, 11 Sep 2024 02:07:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1726045638; x=1726650438; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=jCc0Pk2LOqnsy/+/LSMn62Y8h7zBYg5YqPDf8fsQKV4=; b=Bcyec3xSjXWOirZTSimPyFOlVWr5X1V7ZGTTDFi8TyEpvHiWa2KAOMyVF/mGRToHNn Fk6/Ngc71gTYjBjhsoD/Ppsqqf5Vzzn1KcQYs7hpogrRhR+/fvVzkfHZ6+3mDQiHhX/g 9rvh3uKmeavsvnwHr5xQD2Uvr5CGprsiuPIkWITMy/tMinfe4XYqhIvcf/eIc2qIa/mU Wme2Gx/UuoAI8jdI2rjTWoOBwuaFIlfl28s9zut0ReZuVSLaj7Ed+otWBdJdnMUvWeEt 4TpJrlV3dHWs2vzxZfWWDiFASQ4GaZKGTCPVDFK1t/IO19tUTcIevdEL1k6qI57y4YYH r66Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726045638; x=1726650438; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jCc0Pk2LOqnsy/+/LSMn62Y8h7zBYg5YqPDf8fsQKV4=; b=IX1X11f88VvMiJn5IiVajTKmfd3lyhCa5+wV6EHQfDqV/eBvcE69eJmUIl6yTp2NhK k7H/h5Spu9oE/TaPelplvSslnwdSgXlSigQ925GNSlzTos2yk6+IjSTNGZCkXHXxr2Dg w3XHhDIZuI2KH0U1ndXBDbQV4VsDuQ+HQIbhqD7M3kkoUXCJ7+nPzM/2J8X81zTpNGtK Viv18Rizi+oTVpauCA+RWCqUexfcwShTr+d1b6MYoLCb4gTjrMX3GIimtvkEZW9czmOr SuK79IJTU5juNQJTOVL1LfD/fKIwkvYQuXxMtwMuQTDzLJVHBZ04yEAXrFEmaz502orn 9CSA== X-Forwarded-Encrypted: i=1; AJvYcCWbalMKxI+J6yxMacuPkkp9T0uoqd97KmgVag5zANOnYCIekHofAqe02ZtbQppVbmfXGXl71AEpQmaPyLk=@vger.kernel.org X-Gm-Message-State: AOJu0YyYAm4Nx9C9WxXj7V9Y7RusFOS2fIJ0CJ7luI9Z6th8OkANTu4g m+/TnrHiNUoz/WdwzD/iR4JlmMojyT+ZDqk8/Dvq7Li5NyPa+88QfK/qxVlf32k= X-Google-Smtp-Source: AGHT+IFJwkKixqpXEm2xArUQ1OkvCV/poaUEEYvKfjUZu2BNNxkQ+lrjF/R37qM92DDtapB4I33fng== X-Received: by 2002:a5d:4742:0:b0:374:ae04:c7c5 with SMTP id ffacd0b85a97d-378896a3f84mr10416096f8f.36.1726045636808; Wed, 11 Sep 2024 02:07:16 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:dc:7e00:5389:6cf0:60c4:3842]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37895649b88sm11029201f8f.6.2024.09.11.02.07.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 02:07:13 -0700 (PDT) From: Bartosz Golaszewski Date: Wed, 11 Sep 2024 11:07:04 +0200 Subject: [PATCH v2 2/2] firmware: qcom: scm: fall back to kcalloc() for no SCM device bound Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240911-tzmem-null-ptr-v2-2-7c61b1a1b463@linaro.org> References: <20240911-tzmem-null-ptr-v2-0-7c61b1a1b463@linaro.org> In-Reply-To: <20240911-tzmem-null-ptr-v2-0-7c61b1a1b463@linaro.org> To: Bjorn Andersson , Konrad Dybcio , Andrew Halaney , Elliot Berman , Dmitry Baryshkov , Rudraksha Gupta , "Linux regression tracking (Thorsten Leemhuis)" Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2802; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=v/CIUywqSceQ2rIapI5Q0gb6HopYTWHqEOvnqJ6sKv8=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBm4V28fuMz92TseSVRgJfF+UHFGJzElcDOSNQCO SZ89F2PcjGJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZuFdvAAKCRARpy6gFHHX ciH4D/47tqKjsTOtsjc4ifXbdBdTE6rbhHX4WNqPncJgG/x7WOmCr8cOKraTmovFh7WBEp4XtGd m3FMWntz4ZfQuDQ+bVuBq3/NaNPfHw3SLPEpmsgIE84cM+gICyg+jyWtIF2/WTKnqW78m8eBXeg rk8ZbPQCD1/uz/Q2JUM75m0S604eTWSuupnDenebLow7Z0SyohIS426HnhB67ONrLzOPerNU+/1 dm4DlRmCMrVuLNvHdJFaOwLClinUZWAsEHmUbcVa5rQd14neHehgUfDsJWWcw5npMMYKx8h9ydh QA4DFg+ENCxkkYQCbcoLX8x409oNPYme6te2/v0UZMt3+rYYt3cPjEfRG5q4ML7kAZi87suxKZX gMazBZZy7PP9VAo1pM2su5KFjKtzbJgX86sqS9dNJcG1j7JOLNZNw69neFIioDZ8FITttoDM5d/ 25uBWy+eRkYPL3UkN4nirf3Th731N1sDgx50p6MMfaCOjohi0J5eh6Jirme+Wr7FvZLT4VQ3AIe rM3ymCq9xyRKS/8AhBFB03YrB3GfG4D6GZ2BhvVzt9mJCr9EtavROX5UFs1zLqqxhlrUamCGvka AKeJ7GUajeaOugzDkY+AAu1JB4KDnbxdBowEFre1mZWAZuOVnGitj/NP7WnwovixpZ5wzc2SiSg RpR4A7qMPuLUJ4w== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski Older platforms don't have an actual SCM device tied into the driver model and so there's no struct device which to use with the TZ Mem API. We need to fall-back to kcalloc() when allocating the buffer for additional SMC arguments on such platforms which don't even probe the SCM driver and never create the TZMem pool. Fixes: 449d0d84bcd8 ("firmware: qcom: scm: smc: switch to using the SCM all= ocator") Reported-by: Rudraksha Gupta Closes: https://lore.kernel.org/lkml/692cfe9a-8c05-4ce4-813e-82b3f310019a@g= mail.com/ Tested-by: Rudraksha Gupta Signed-off-by: Bartosz Golaszewski --- drivers/firmware/qcom/qcom_scm-smc.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/qcom/qcom_scm-smc.c b/drivers/firmware/qcom/q= com_scm-smc.c index 2b4c2826f572..88652c38c9a0 100644 --- a/drivers/firmware/qcom/qcom_scm-smc.c +++ b/drivers/firmware/qcom/qcom_scm-smc.c @@ -147,6 +147,15 @@ static int __scm_smc_do(struct device *dev, struct arm= _smccc_args *smc, return 0; } =20 +static void smc_args_free(void *ptr) +{ + if (likely(qcom_scm_get_tzmem_pool())) + qcom_tzmem_free(ptr); + else + kfree(ptr); +} + +DEFINE_FREE(smc_args, void *, if (!IS_ERR_OR_NULL(_T)) smc_args_free(_T)); =20 int __scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc, enum qcom_scm_convention qcom_convention, @@ -155,7 +164,7 @@ int __scm_smc_call(struct device *dev, const struct qco= m_scm_desc *desc, struct qcom_tzmem_pool *mempool =3D qcom_scm_get_tzmem_pool(); int arglen =3D desc->arginfo & 0xf; int i, ret; - void *args_virt __free(qcom_tzmem) =3D NULL; + void *args_virt __free(smc_args) =3D NULL; gfp_t flag =3D atomic ? GFP_ATOMIC : GFP_KERNEL; u32 smccc_call_type =3D atomic ? ARM_SMCCC_FAST_CALL : ARM_SMCCC_STD_CALL; u32 qcom_smccc_convention =3D (qcom_convention =3D=3D SMC_CONVENTION_ARM_= 32) ? @@ -173,9 +182,20 @@ int __scm_smc_call(struct device *dev, const struct qc= om_scm_desc *desc, smc.args[i + SCM_SMC_FIRST_REG_IDX] =3D desc->args[i]; =20 if (unlikely(arglen > SCM_SMC_N_REG_ARGS)) { - args_virt =3D qcom_tzmem_alloc(mempool, - SCM_SMC_N_EXT_ARGS * sizeof(u64), - flag); + /* + * Older platforms don't have an entry for SCM in device-tree + * and so no device is bound to the SCM driver. This means there + * is no struct device for the TZ Mem API. Fall back to + * kcalloc() on such platforms. + */ + if (mempool) + args_virt =3D qcom_tzmem_alloc( + mempool, + SCM_SMC_N_EXT_ARGS * sizeof(u64), + flag); + else + args_virt =3D kcalloc(SCM_SMC_N_EXT_ARGS, sizeof(u64), + flag); if (!args_virt) return -ENOMEM; =20 --=20 2.43.0