Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2097500lqb; Mon, 27 May 2024 07:48:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7BBwj3uIK+BZ59xH2KBY4VnjP0hO5l3opfD2l4++OjYO/supPqucaXUpANpr6wVPIBKvm7MhJQLof9d+2qx6MCcgX8KqtxkU+eqxLNA== X-Google-Smtp-Source: AGHT+IFMKBBeTllRE+HRjl7KaP+7xdjG8oiW4CieSum9yKO/5ekll8nta2b7vDAFnfXHBRcLNS45 X-Received: by 2002:a50:cc4a:0:b0:579:c8cb:ec4c with SMTP id 4fb4d7f45d1cf-579c8cbef27mr2929100a12.1.1716821333364; Mon, 27 May 2024 07:48:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716821333; cv=pass; d=google.com; s=arc-20160816; b=HYUPqNkODkRsxEp2myWSV8enFU1R9OWlhH70pETg+WrXGFguGeSUj/WczjY6tZWZ2E hmOccjgUiw4KugyHmZ/kz9+doGrvUVGEc0VJt0TTtWffPhe89x75eXTfJ08mBP4BZT/p Kc5C3kD1MgXurNmZWjeXUe0giaUJkSTYqZurDjfn42eojZpcJSuTWTmoQngMA69GJL/c w5qRQAXBBMKH0puDpHen/id8Utytf+zVST8vPIhr8vqlBzBtJtaAgF4A7PVypLBjk1Ds J/S8RKVxAlNJ4VedFn+K2tnpSei6o59iJnZIFYJRQnSRK/j+a7qCzBuLoVSZvgJBNeQj SiZA== 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=ecomYrTqMez9BfFTVNVfg4bDKKi23IWg45p2uMP1nm6HIdaCMu47lCZKRjlcvbzWTd aZ0VzeNoNc8U20++TFSnq/N7MYLwSd+aC96VtUrR+B2efIgoUoHerUfDQDTvdyL1hFgT v5MoLxnZWdUZuLizFt1EM7IJHp8pyfLNq4Ar3Wu7FZlwsLmoYOtHpu9DRZtBvH9OJl+y sojq+t/IWePLe/8lRGj2MPlouZ34h/qrXzNPRvh5dRdwDpaYGXWK7tIDS8Opj1oXIMHs 1URErLZ/PMKAuRvrMVU/Ufe04w6ucPFGyewdjwebmnC2lDI4fiJys/iTdSEV9mBhDcdJ adCg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g6P9pAIN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190932-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190932-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5785245f99asi3969446a12.248.2024.05.27.07.48.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 07:48:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190932-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g6P9pAIN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190932-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190932-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 191411F20F18 for ; Mon, 27 May 2024 14:48:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A914167DBA; Mon, 27 May 2024 14:19:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="g6P9pAIN" 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 BF583167D9A; Mon, 27 May 2024 14:19:30 +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=1716819571; cv=none; b=lTS3TdVRUr1F3datnCLRBOwjKuKlW7nbz9WGBuLM/9gxSb8FFJDa32kS332o7c/zQBmsf0Tx941GDr7GSrEJztKm29dtiFbF+ZtEis9daxFcmv4VLbbsw16dCAVKYbvChPdmDw75EZFtxJgdCvc/QVoEokvPIOkXucZBfSFadyA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716819571; c=relaxed/simple; bh=sCvrPt4WIobpFxpQmj0P7zdxczqjn5m5qnrJFzhjgTE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KsdKKLAaj+P4sqdmChvIsnS/4UPnItCtrTYaGTLCO+K6ImI69jAZUqYOZFlK4WHUYRNKZGjNog3H3Mw7NJIdl95+g/MsM2gTmUbR3FrwC6rqaWfbaL+qZLDRnsthgvQeQHKEI0uLQQYiSDjBVjMBi1u76mJI3xZntkSX8jbzuDs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g6P9pAIN; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52011C2BBFC; Mon, 27 May 2024 14:19:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716819570; bh=sCvrPt4WIobpFxpQmj0P7zdxczqjn5m5qnrJFzhjgTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g6P9pAINNo07ZnUuMnjN6VyZxNCQUYbEdNrhvTqBy3SmyN0L5oQLZdDYsss8yM58X zMvAXgCtVb0n8tsk2wW+aWhApelV8f0JL97vJ7uEkdoN8eZNNZ02H6+C/KeLyvpRnc 7AWwne/uQeHVhDyFOVyv8m7/u25qh5a5CLmpQCBFubtLQJ4AOlPM6ox/fuRcNoBTeo ARPQizpsvkksxzNuZ+yM5E+K0ugkrfzbvb0iOwyC/P4VKLDJxGvUQPhim2Ls+E4PA9 y4/115iMrTslwf6j8yJ6ABq45ZiYxNgughGkYdOw86cPkpyfBtycKafg1d7ZrELynK 1KRFpxlVEDJbw== 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.10 08/13] kselftest: arm64: Add a null pointer check Date: Mon, 27 May 2024 10:18:45 -0400 Message-ID: <20240527141901.3854691-8-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240527141901.3854691-1-sashal@kernel.org> References: <20240527141901.3854691-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.10.218 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