Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2798735lqt; Tue, 23 Apr 2024 01:43:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXPHPXhECr8j5yXZfsfcVO5pXjJ5hx5zEUMNZr5/YNxaGODlL1T8j9QSrnz3OZtYEBidqu3cegPtUqBNqGQ4EHMmnHP+V4idH60+f6Vyw== X-Google-Smtp-Source: AGHT+IGi6MM8ejiYKDq11UgaRJ2l486zlqfmdeZJJtWSM28iP1X5u2btn0LZKRKF3NzXI4Ah5iRA X-Received: by 2002:ac8:7d13:0:b0:439:6d9a:b914 with SMTP id g19-20020ac87d13000000b004396d9ab914mr14218483qtb.58.1713861806663; Tue, 23 Apr 2024 01:43:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713861806; cv=pass; d=google.com; s=arc-20160816; b=h62j7DzQR+l4zrlpxuG1I2GfbD+EhxDMX50D4U8+bGDOcQAl5NZnkGKe1iytRXQVkN nxtLdtnNorQEq1bku40QhYJTHe14Mrvf56UsbSFAyNsZ3RtO45dIMFeEq5rSejCqTHcz /ndLnOce5V5dTcqwvMfhqvWaxAHVZFObaevZrwUFHDybwa7ckJvxMo80z1LgDaUL3q59 lANJ7pED4EAhEVg/3OCqQnyeA87giCY3C6hxMbfGVm5z76FhPZnngW8rmidNVkR5gVQF icDgh8P63wR2XEdZQv6Sumbcp+4MAhE5ciPqQKX5f5xAMYinl63Py3AQLViRdpqSmfb+ aDEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:cc:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=5HLjiQ+B1o3LKKMfqydtLDi2f98uxHa7c/XApddhheU=; fh=vfnuEGD6qbVBpD/PaHl1ycVuzzbCrP5HlKuWPIhhcHE=; b=jfCjp2PV5rxmokgRHUr88Ud327TWCaPhfwfAgTG0F5CRD5sVMd9+ObFRraorwoxYLZ LJYlzqM8osHWxiqe6GkM5vhdmO89echngdEI0eHCOvK8ki2pbchnrfEFIg/DooyYLpgO A70MTi/zjoToV09YNX04xI8LYs4Z/pxlPlkeDaTI8p4jBhRS34Dj1XwZjmMM6vqym/r+ bQya0rXlX9SplSw75AsEPPJ0W3PPHXMCHJnBzz52uUKv7qwCwqSTi6F2nWpczUbvi6C5 ubaC+ZJ6mAw7Qne6wkQ9z80559/lwED6JbXUDkHeCYZ4Fzq3Z1AKwet5fGYY9mAoZKpz kGtQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=fzp7ISOZ; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-154712-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154712-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g7-20020ac85d47000000b004343a018c54si12210122qtx.794.2024.04.23.01.43.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 01:43:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154712-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; dkim=pass header.i=@collabora.com header.s=mail header.b=fzp7ISOZ; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-154712-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154712-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com 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 E76171C22BA7 for ; Tue, 23 Apr 2024 08:43:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BBE7254FBE; Tue, 23 Apr 2024 08:42:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="fzp7ISOZ" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 56354320E; Tue, 23 Apr 2024 08:42:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713861749; cv=none; b=qr89vKFZqXK7kq4FHIywEZ5DKkTSvqOUpmM73VCsUwXXcWUcffZafCKrvjsIqsmjiv3vVVzcIQ4LyI+89/P5yNAnA1M0WA8CFEmI4NhnQ5R2Lro5MHVusFxm6EvYVZLHIaYLGpt6RsHtdVuUd8dwARD5ykml61UASSe6huuBTHI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713861749; c=relaxed/simple; bh=lCEgH6CjISLGxTFDuXB9DyweUCZb4U8cml+VeZJsxb8=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=Ly9gL5wQAkkCsbJDg02PAk+RHgsjcu1lgcNniLlV+gz+Pwvm8guHZ6sKv4I3OByidPqIRRzTrLt2aC8ZJ+e/f7rc6Niccm9+lzrYQ+Mdj0PC/QVPF1mcgpFYuNg+HRj9BPPIQVP6x4wv3Y0yL7nGUAFoiULn3vMOBIgpCfI1MY8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=fzp7ISOZ; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1713861746; bh=lCEgH6CjISLGxTFDuXB9DyweUCZb4U8cml+VeZJsxb8=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=fzp7ISOZTZr9+iDobVs6ZrXUUgMj/2HKNiqi++bWH1yrgi0BBaw/5HPRADC5gSZPF AF0AD+MWcLZPUht2FcDsov+eDyXcX3TQxl95tqFmMh8BMsKgvSq8rUNsurpHwiptAV sbCQBP+edEMGYOcpk3HlkV/TxHxrE8WIfStYP8p5vUZvW+o0wag0btWoUKcntDl344 VOZ3HpLkMs/YJT18LDa9O/hLofOJCxyNuDBAu145pZnFQULT+oEFE3Nx22Cs/NswBe 7IxVByNuufNWddqj/X116zbdxG05ItoUFoYfOeufLwNkGfK2SoIAofLnOQNLw5s2v1 yctat8YJbky+Q== Received: from [10.193.1.1] (broslavsky.collaboradmins.com [68.183.210.73]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 28D363780016; Tue, 23 Apr 2024 08:42:22 +0000 (UTC) Message-ID: Date: Tue, 23 Apr 2024 13:42:51 +0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: Muhammad Usama Anjum , linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kselftest: arm64: Add a null pointer check To: Kunwu Chan , kunwu.chan@hotmail.com, catalin.marinas@arm.com, will@kernel.org, shuah@kernel.org References: <20240423082102.2018886-1-chentao@kylinos.cn> Content-Language: en-US From: Muhammad Usama Anjum In-Reply-To: <20240423082102.2018886-1-chentao@kylinos.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/23/24 1:21 PM, Kunwu Chan wrote: > 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. LGTM Reviewed-by: Muhammad Usama Anjum > > 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/testing/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" The test isn't conformed to TAP. Maybe the next patch could be to conform the whole test into TAP, would be easy and straight forward. > > #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); -- BR, Muhammad Usama Anjum