Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2085969lqb; Mon, 27 May 2024 07:27:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU3Wy6aOk6cyg95YYpt4MFwpNA3W8PTAo/NEL7ulorA6KkWLwSYOKkvxDKKJ/Lu3gIqNRpitRZk8ESDI+SXM+frFiHO0DZQk4J02YKaWg== X-Google-Smtp-Source: AGHT+IG3sNWhvCEvrmXKu7rtErItWTfPJ+q30TIl1/rJx4f6UWAy8u2mtP2KeHagI5xmDGKpRcqg X-Received: by 2002:a05:6a21:3417:b0:1af:9728:de86 with SMTP id adf61e73a8af0-1b212d382famr10569120637.32.1716820049498; Mon, 27 May 2024 07:27:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716820049; cv=pass; d=google.com; s=arc-20160816; b=aCM0zg+cVpNdR3luP5wFb4zuNEfhFtOatGiyEiUFr5YnlnvXregm+tGhdt3Pxy2HD2 LaDLoiVF4xNUDiCIYNcNl68E+Pt4OQ0Q7DI49vraa83DTxypeRadZXcJKLLjr+2hsfdZ dtS80997ahY0RkhaC6w1LbLBhH3caWy4QnmMxTZmX7kucudKxEH8/IxrZONP7rlZ83sd TZA1ervrn3q4G9j1TWN70TdKHh447wrszIqS21GvrqGkCPRQXqlk6OS9sUjVTJhNvnGu bfsDeQJWxFPjxkfGNZxpXsEoEMe56p5QgCq6ArDyqwuBcULg/mGuF8wQ+DaFIq19AF1Z JfUA== 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=R1EVyPDU/cl8oOPZR+KJdmKHQyeStD7K5pk2O7Pn3yeZiA31M44jilgYZw9RS6A7mo UK7ELvIxMumVliEsux8xBPPrU3O2yYO1gwvQWUAsE7FGxaonGgBDtqPIpK5tOXPG1axM IEb8SOhN3jRxwIDb9ZNIhEKaujRwQ50FVSs+ToTdZQrAR5zqb3uZ2lCWZzoLuf1FvzYs t60Y7hJsCg0Z/WBDPE4OwmmLII5kcpT/lVp2kQ19Wq8TfZ8Rc6CBuQWhlGazS0uzvRRJ z8oCPNry+Vf1232p8n5EPb69ew4T8K6/2/pW3K5ZL7pLmTyn/iTTFse+Q1XOWk7KExzv yDIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="CNp+/j79"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190854-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190854-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f8fcfd850bsi6097318b3a.191.2024.05.27.07.27.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 07:27:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190854-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="CNp+/j79"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190854-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190854-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6C21D2A5814 for ; Mon, 27 May 2024 14:27:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 064DB179641; Mon, 27 May 2024 14:14:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CNp+/j79" 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 2BD8A179675; Mon, 27 May 2024 14:14:57 +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=1716819297; cv=none; b=YTSsD6g0OERzmfWTAL5fJ7Hg/TARZ9eRF7VChSQBMUe1Vvb86PQyvyQHIeLtSct3GvVTa7IGDqlN+K8KcWp+dM6a7AUGrJKPwtdT4V5FLtR6ggdGsKTXA7TMVzGNIPAhLF4a7hDtIAU311Q6puIPpuL43F5ZJOHWWm7IUJlwpoI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716819297; c=relaxed/simple; bh=sCvrPt4WIobpFxpQmj0P7zdxczqjn5m5qnrJFzhjgTE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WNvcBFxBoos9gxaMlZhT+Vv4I/aVq+H79YWrpZbkr1CmtraZPZDDjkWYHDOaMZCIvg/JVmJ4qLE1qilXW4USusIiYRttscUotEi/YAjZRnpK1HHLZb+OC9ppoCYbB/aRM5DIuCPf6wiwPrkiqxlZ9ZZUr6Xz/VBHRqxw9v9n33w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CNp+/j79; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9A28C32789; Mon, 27 May 2024 14:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716819297; bh=sCvrPt4WIobpFxpQmj0P7zdxczqjn5m5qnrJFzhjgTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CNp+/j79JMbkD+VbSEOImNDMUWi5ahQp43yy019Rm4MjOObaIyTmpW93TiE4IPSQl eBMRwVMuQug7bcsoBqkjRRYVH/a/ZW0DMSt0VJ/oYXGSdrgTNN8Dr+g0jrpBn8LuwK vs3VxWgBuyMzeV75U4t3isCylLLLIN69rPKGUAiqUYBnvWrNRIIZE+M/hhTJoxhZOG ir5KE3J0jJUAlf0kHf03egJv1clqnlmZ6gV81Ms0C4EHVGGcgoW7/LhYehu/F/qwPr BW/h7nx/WZDMuQLLMuUpuXwizDjZA+YdhXnzmovsbkyyVZ/BVlz6XK5+9CMwe1UMdQ kSWUcUhXgheQA== 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 6.8 18/30] kselftest: arm64: Add a null pointer check Date: Mon, 27 May 2024 10:13:27 -0400 Message-ID: <20240527141406.3852821-18-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240527141406.3852821-1-sashal@kernel.org> References: <20240527141406.3852821-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 6.8.11 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