Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp425467lqo; Fri, 10 May 2024 04:22:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXSsw6xSCLI/0zbwE2Q29RDFIYFQ9ub8FjcN7To6zuX1t4NTCzffhEdyMyIfanSPzYNngNw7pSBOe3lbJBcIrAmy/GF7dPJUI+etXqR8Q== X-Google-Smtp-Source: AGHT+IFuuWb0+HMde+VJASHzsa/+riXxBw8UUb7ynQpAtIP1tyH1bPEYqDzduqieKExzcnNOksQU X-Received: by 2002:a81:524e:0:b0:61b:3356:f1b5 with SMTP id 00721157ae682-622affabe11mr25592807b3.28.1715340176514; Fri, 10 May 2024 04:22:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715340176; cv=pass; d=google.com; s=arc-20160816; b=Vcyu2pXv3nrpGPL6INgVNEAGJ8CpnJv5W6bJeIhTIsAbwj9SZniyGRe/9uezCc9Thf RFG5DA47rWmkJTL+kAykXKEZ0MWeUVPKLHIbAIKns+8nBB1EMfoVhLX9vy7hWQbo0iVj PvjzirGMon7l5sd/tTmQnRPYd7KcDOwi33tIpxgw6NpuQZZR0LHgyNGMSlEeNKwlXiLy sAd2dcPEPP1vK8KDprCjTXDAZ97JrNdoEiz8LbbFdz3AY4j0fVLP1o10vfOZSn9+xg1W KEULZGAa+LPkX80ell9WrzHCza8n0vru9QRJZOGxcPeOCNllwuqdNrsDNwlir/z+/0n2 UAxw== 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=e3njiETN3bLnawP5kIxfbkoE7Wp/JAEFW1iW8IzsqEE=; fh=Icz9E8DXite47jto1J5FDKj9WwOAR7K0spywDAVWNP8=; b=Qh0z/knA6KsEArYSK642pe3cXgy9sjKmoY/9shlIN6OZMD5bNDD+7x3uChr89WV22U vD2BQHROZU9d/CzEL8ghInE73JTTOk1r4GWzcC8hFvvfQS8siAIkli/zDc06eczO/tv5 glf0SGN2jbt7x3Om9/QRYNq7iQn+hUaXQF2BjmLnp1+1AiqoRpWqrdgXwOZ61F6c2saj wU8dZSxq2t3KjS8ozDsD1yZUob0KISanUKWRZ7kT3evJ/g2lnb9obt9Eryfmx16RMWs3 xXp2Yj2TVw5rs/uX+Ug/bRLp0aX5BG4T+HrHfe/q51pGnegAfCFGllSeYKxyqZFjfgKQ lEzg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="A/6t1HAQ"; 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-175650-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175650-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. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43e05ddd2dcsi2526741cf.481.2024.05.10.04.22.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 04:22:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175650-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="A/6t1HAQ"; 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-175650-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175650-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 26F9C1C20B40 for ; Fri, 10 May 2024 11:22:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 874F016F90B; Fri, 10 May 2024 11:22:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="A/6t1HAQ" 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 0DF6854662; Fri, 10 May 2024 11:22:08 +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=1715340130; cv=none; b=KvNJFoMqC1bYb2W29pta+O1f2WFQgtx2SG+rplv+Zh3rQ5bG+6Ysa4lDmljgjFaQRmlkflKOnFNCWYns/L9VmElQlMixWgyyZUxE0P3a0aF7CAWbiRWWnHvYQQk/cZsdbRgHnsj3r+8u7T6mqYNK0wTpcTwApbP+j3g3bL1/oN4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715340130; c=relaxed/simple; bh=mSAKbILicGZ2jA5iMQsYhrs50+CCyAKG0Vj/7T7WIbs=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=u6rV5+jKMnb4zL/KKmGeLTGkp+IGH3ZW8ivr40/vSA2+FnELCsk1nqCaTmfAjBuNLPKoBDMBSy55KBcfJSgLXFPp72KcR0/HImlzijbAziRlEuavyxlKG3RPjJ+G3xkBTpzWL5oL8dQlCUUk71Wv9owVkurbOku75Jw8MZ3eCI8= 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=A/6t1HAQ; 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=1715340127; bh=mSAKbILicGZ2jA5iMQsYhrs50+CCyAKG0Vj/7T7WIbs=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=A/6t1HAQ00Bj/IZpnkIEAylqRa9rLnfmYz/sCKuUB6k1TPeLsjsFqOPIfTBwTbfF+ hNIdfIbUWitan2i4UUPD1UpcGmF5C6ZouZVjnRCys4z4Nk9Bx0LdH0iZRN0SLuXD6l HRlXrcqJ5CQOw534nw9RCz82ihmHofCPlnYt3J5ntuFWq9fvamRzSEq4CkEUgLyAKl mcSiKT+Ml58yxsduGrCdn4kYavQHEdUutFDHtpuhufu+pD+kkAlx4RcfPDTYAz0LVX IdWWXhh1e/4m2rYTkvJQ7hYpY/c7IknWzwlB3/dKn8t1tcukxa/tvVQlU94bEJ/XHO VKWCFNAx6NfMg== 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 A8AFD3782185; Fri, 10 May 2024 11:22:02 +0000 (UTC) Message-ID: Date: Fri, 10 May 2024 16:22:27 +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 , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: Re: [PATCH bpf-next v2 2/4] selftests/bpf/sockopt: Add a null pointer check for the run_test To: kunwu.chan@linux.dev, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, mykolal@fb.com, shuah@kernel.org, kunwu.chan@hotmail.com References: <20240510095803.472840-1-kunwu.chan@linux.dev> <20240510095803.472840-3-kunwu.chan@linux.dev> Content-Language: en-US From: Muhammad Usama Anjum In-Reply-To: <20240510095803.472840-3-kunwu.chan@linux.dev> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/10/24 2:58 PM, kunwu.chan@linux.dev wrote: > From: Kunwu Chan > > There is a 'malloc' call, which can be unsuccessful. > Add the malloc failure checking to avoid possible null > dereference and give more information > about test fail reasons. > > Signed-off-by: Kunwu Chan LGTM Reviewed-by: Muhammad Usama Anjum > --- > tools/testing/selftests/bpf/prog_tests/sockopt.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/tools/testing/selftests/bpf/prog_tests/sockopt.c b/tools/testing/selftests/bpf/prog_tests/sockopt.c > index 5a4491d4edfe..bde63e1f74dc 100644 > --- a/tools/testing/selftests/bpf/prog_tests/sockopt.c > +++ b/tools/testing/selftests/bpf/prog_tests/sockopt.c > @@ -1100,6 +1100,12 @@ static int run_test(int cgroup_fd, struct sockopt_test *test, bool use_io_uring) > } > > optval = malloc(test->get_optlen); > + if (!optval) { > + log_err("Failed to allocate memory"); > + ret = -1; > + goto close_sock_fd; > + } > + > memset(optval, 0, test->get_optlen); > socklen_t optlen = test->get_optlen; > socklen_t expected_get_optlen = test->get_optlen_ret ?: -- BR, Muhammad Usama Anjum