Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2095287lqb; Mon, 27 May 2024 07:44:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZ+SoWul/KkGt7PTevPnwzxzD7RsTxxBGDjI1xmXmRijNhycLf2giRalkqmdBuwnXBlDMy0nyZ4CwxlJeZbdJhADFDvJ28YxG6uX5mcQ== X-Google-Smtp-Source: AGHT+IHslUqcoNmdMMsBH4jsXqEpsrH2wx0+exltBNoYjKZaYPYISGJX2fmxdawWjg8VvoL20Oin X-Received: by 2002:a05:6402:2904:b0:579:e853:d388 with SMTP id 4fb4d7f45d1cf-579e853de8amr185970a12.13.1716821058406; Mon, 27 May 2024 07:44:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716821058; cv=pass; d=google.com; s=arc-20160816; b=heUgeikeUATQqKghuhmQtNtObApfZCos1UGZZBGp19DaM6eU2wV5Q/9vdDytVi/RsU RQunPjvmzJ+RB6qtZffLo7vXX+L3qY2XqfNktWzApDb5+5VNbQ8IWiQCS6SaZE99g+N8 ik+5Dpl0ZJmJMi5ZyIg/+TNZa0h/P4ColJEz38CqENSyaM92C1m3/0baRMgq73unP7GU gM4jt3JGinTFe2AMHRE8Pnc56jAaPwnwiClypyDr8EcJcoHUOrg0BbmcMg4UXYwPBRdf GAHe/JeDFXUl84RBi4yns/vrdzCHm6lWwCM8Lou1eqYfQSTZecFPcXKyh6hEQH1mDHE8 tq7Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=gjyCbA5Y0Dx4PQd6uXV/HVTjmxABCdFebBxzcvUiKps=; fh=jNO7Ehklk4e8DpaehEBjf8Dn1kxIil7cUM403s92DOQ=; b=V38ymZ11wIrZTSnKxplcXg9R02Klx5JxGtuyEmNygE2OUlvJx9O0ACVjXd4MLg2AUr J2znq+O6dblhvXcogd2DjjR++B81UhkoetmWJGNZmUU9C1DteakOJzohdJpIYGNeLcaI csJskJ7SEmIf4M4GidOn0kHCqG125pEJ1+WWUjwNBgFuZA/YaeflayOhE42HZ3qN/0Vb B4WHm5wdhhfaEFtCMxq5APRjJmbouiLSGaYBJawR9AXA77I7eXWdVLo2b0oRVbnVIXBG rEpINPek/89XZcI2oMnMbrFT95aq7k/D/XZS6/dhZ56mF8t1vJu8qFOizCag9DZ9lPqh /X0g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i8D+O5fH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190919-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190919-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-579bf1bde62si2532856a12.276.2024.05.27.07.44.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 07:44:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190919-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i8D+O5fH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190919-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190919-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7F6F21F218BA for ; Mon, 27 May 2024 14:44:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B468C61FFA; Mon, 27 May 2024 14:18:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="i8D+O5fH" 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 D8F7361FEB; Mon, 27 May 2024 14:18:36 +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=1716819517; cv=none; b=q0uDcc+jz8AX473tuIxKuFNZsU/eXKMZZKTW/A8/SbXry3boKF6n3MyGwIHZ3C1AnpU8AKKGM/eEo0jbshWqDQP4lughyQajJha+e0pKTM3dp7/sweHVkOVoMnwyOzoHSpqFw6q4uRfOEYo6mXyYYw/HZm5DF5NMRSZn8RNr/k4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716819517; c=relaxed/simple; bh=sCvrPt4WIobpFxpQmj0P7zdxczqjn5m5qnrJFzhjgTE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P0ahq0/KSZDwHlwbwiZSnJdIOiQzSNfC/mmwKCS8l3Yr2Epos50cK9ToywqNOJXlVo2b2qMcc7oTUNLJs9lKyw6oZGWFlr094Ns9kJiGgiV+o+E+2XYLOrC268adxAo5AARJC/Fi8/q0h5K9bimL4e8vC1iJToobl9r80HT2R28= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i8D+O5fH; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88656C32781; Mon, 27 May 2024 14:18:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716819516; bh=sCvrPt4WIobpFxpQmj0P7zdxczqjn5m5qnrJFzhjgTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i8D+O5fHRVxNqMGBllpdrRn3ja1tOzmQi25ld2N04MFsT6H40eTv3qQcu0afvkl5K qybr8uKLE2mA6LlbpXKy8A5foLr9rieWfSUzH0RnWvSjVwfORFS6BKoE2PsD5c0LGp S9PTGQWTIghYTlg8zWImJhpmeYcVt8v07Bd74cLwBkZ3dVtDpWSFl2gmZavHgOLGXP Ex+kRy0vaS3aBqV/mGzXq17+Uf7XNNWIETAa0UKmmXZRBHglZud6vV8tvlozCRnodW frQEnMhc6ol31mjHRt5WHXlXK68QBUyA82EP+trXQUkcaLtoxSgH8Qi9y3/ufJETL3 fx60yy+TmHgcw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kunwu Chan , Muhammad Usama Anjum , Will Deacon , Sasha Levin , catalin.marinas@arm.com, shuah@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 08/13] kselftest: arm64: Add a null pointer check Date: Mon, 27 May 2024 10:18:02 -0400 Message-ID: <20240527141819.3854376-8-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240527141819.3854376-1-sashal@kernel.org> References: <20240527141819.3854376-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.160 Content-Transfer-Encoding: 8bit From: Kunwu Chan [ Upstream commit 80164282b3620a3cb73de6ffda5592743e448d0e ] There is a 'malloc' call, which can be unsuccessful. This patch will add the malloc failure checking to avoid possible null dereference and give more information about test fail reasons. Signed-off-by: Kunwu Chan Reviewed-by: Muhammad Usama Anjum Link: https://lore.kernel.org/r/20240423082102.2018886-1-chentao@kylinos.cn Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- tools/testing/selftests/arm64/tags/tags_test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/arm64/tags/tags_test.c b/tools/testing/selftests/arm64/tags/tags_test.c index 5701163460ef7..955f87c1170d7 100644 --- a/tools/testing/selftests/arm64/tags/tags_test.c +++ b/tools/testing/selftests/arm64/tags/tags_test.c @@ -6,6 +6,7 @@ #include #include #include +#include "../../kselftest.h" #define SHIFT_TAG(tag) ((uint64_t)(tag) << 56) #define SET_TAG(ptr, tag) (((uint64_t)(ptr) & ~SHIFT_TAG(0xff)) | \ @@ -21,6 +22,9 @@ int main(void) if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0) == 0) tbi_enabled = 1; ptr = (struct utsname *)malloc(sizeof(*ptr)); + if (!ptr) + ksft_exit_fail_msg("Failed to allocate utsname buffer\n"); + if (tbi_enabled) tag = 0x42; ptr = (struct utsname *)SET_TAG(ptr, tag); -- 2.43.0