Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2790784lqt; Tue, 23 Apr 2024 01:21:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXTTcJeFzRgTs7+73F7hp6Vu5SqkNJzZ+AEzUczOwKrYoSGkL8OPEnDBULSFD7VBY6fCDQgHbZwFNHpm+bemVJ8aPic/L3fPYrfIoj4Gg== X-Google-Smtp-Source: AGHT+IHUtGv1Sv8NXS6MNej8zB/B4vJpc3owaN0aOu6waMryL6yO+VfKPKBmfy9k5hoUEiItlyre X-Received: by 2002:a05:622a:4c8:b0:439:99fb:b240 with SMTP id q8-20020a05622a04c800b0043999fbb240mr8925318qtx.47.1713860486644; Tue, 23 Apr 2024 01:21:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713860486; cv=pass; d=google.com; s=arc-20160816; b=e9L/UumbtUrE7ysmhhuFKcPyGcKa75Nv8FE+yKzDAbUdzaw547NBBu38ud8/EWayWf f/fiJLpSTMzYVLckW3tc/zpfEvDEqy1sOEwym82stBbelvc04yfS9Q6mUonvw3+o0b0t adm4Df5Oll8f1U0ThvUfHRD9ZE1z9kRDyQzcHjO3PP3sb64swjkp06WFRsjp2e76Y1jN Lz1N5DMUHz0XyqCESGLnqTd1BY/L2sLH1kh6UJO2Wg9a40lfUS/KPwRHn2ruyC0XET+x bAL0g0zz5bz4C8bHE6gk67+BUHs1BZ9ilOShmtV4n2BsN9lamSp+Dz9W/LWHKYMZ3Ifp ZiGg== 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:message-id:date:subject:cc:to :from; bh=IoVwL3F2ukjJwA+YLTxtNJ4TAReY3us4D/I00WA4cao=; fh=3dRz//fuxhAmUyLM+CSs9Y//+TTWrN17uomPOCNlCl0=; b=LNAszBqnHwS0v74m8g53B5CfGu9E9r5bX1OOjNRmR6DZ9XWsaGBklfPlg24b8Pfoxj LPGdqnppWZcw30NiS9aYwsgjy7UREFJxaTxEaOHwA4nyUaLkphoH0gTR7sbDnzzbgthO EKybDESmLz1p/gPhWZyVAq8seV8wUDCxty1tleeBI2CVlgjhL6usZn9DGtNy3MYtvIkr pk9GnAIqGBIY0cD7DtmneQRVw3f+2kbcIbdFAqsP6DGRHtvfZef4hmwtAh8J6ujUNfrY uRmD00F/02OaPXW9j9f+ge+b1hBHYxywZDDx9POgqVsiyI46vKP8EJWGx9aYOoRxiL0q WYWA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-154673-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154673-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id m13-20020a05622a054d00b004366ce5dca9si12454098qtx.454.2024.04.23.01.21.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 01:21:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154673-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-154673-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154673-linux.lists.archive=gmail.com@vger.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5DD2D1C20D08 for ; Tue, 23 Apr 2024 08:21:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5BD535102F; Tue, 23 Apr 2024 08:21:20 +0000 (UTC) Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 A3A272B9CA; Tue, 23 Apr 2024 08:21:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713860479; cv=none; b=F5m312cHtZBEe9vewIsdiVlP4U0yINNoZ2SgICQ1XAC6sb6HnP2J+24gWv9YCMb4jzRJg5jxq0PL3D6hwT9HCJd5rXQRLMSCQbg7Zf03YgSm6YWA9gPspInbzne8BLjlIgQ3DPKOJspPb342nqnHOFvObooORmYDFE+8vShtgfc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713860479; c=relaxed/simple; bh=XR0D7pBSJ8zL0ehkLgrKl/VftX9RMVYquoldIGOgs6c=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=OE4zhJ/Dkvi4aZR667EbDTSJ+tRNQtU1bF+EyQa0KlkBWMgIF0dBnVS9bXugLGiCVESg1iLTEjiXtmxK/G9DcEc/56rWUoCcANSoYe7nzekBEgPyo7ErWkvwAZN3Y4tb4k8UNbj9pOqJn5e53tJ8MMbSgmtb6Y6lr8fndrZ0EnU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 6ff26ee8014a11ef9305a59a3cc225df-20240423 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:654bd083-8eba-4279-a533-ecdf506ed35a,IP:10, URL:0,TC:0,Content:0,EDM:0,RT:0,SF:1,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:11 X-CID-INFO: VERSION:1.1.37,REQID:654bd083-8eba-4279-a533-ecdf506ed35a,IP:10,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:1,FILE:0,BULK:0,RULE:Release_Ham,ACTION:r elease,TS:11 X-CID-META: VersionHash:6f543d0,CLOUDID:45b6fc79502f8c3e69b1d2ea634563f1,BulkI D:240423162111G3G0W0VE,BulkQuantity:0,Recheck:0,SF:66|38|24|72|19|43|74|10 2,TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC: nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: 6ff26ee8014a11ef9305a59a3cc225df-20240423 Received: from mail.kylinos.cn [(39.156.73.10)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 1541249360; Tue, 23 Apr 2024 16:21:08 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 9FB1BE000EB9; Tue, 23 Apr 2024 16:21:08 +0800 (CST) X-ns-mid: postfix-66276F74-448055614 Received: from kernel.. (unknown [10.42.12.206]) by mail.kylinos.cn (NSMail) with ESMTPA id ACA8DE000EB9; Tue, 23 Apr 2024 16:21:06 +0800 (CST) From: Kunwu Chan To: kunwu.chan@hotmail.com, catalin.marinas@arm.com, will@kernel.org, shuah@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH] kselftest: arm64: Add a null pointer check Date: Tue, 23 Apr 2024 16:21:02 +0800 Message-Id: <20240423082102.2018886-1-chentao@kylinos.cn> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 --- 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/testi= ng/selftests/arm64/tags/tags_test.c index 5701163460ef..955f87c1170d 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" =20 #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) =3D=3D= 0) tbi_enabled =3D 1; ptr =3D (struct utsname *)malloc(sizeof(*ptr)); + if (!ptr) + ksft_exit_fail_msg("Failed to allocate utsname buffer\n"); + if (tbi_enabled) tag =3D 0x42; ptr =3D (struct utsname *)SET_TAG(ptr, tag); --=20 2.40.1