Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp150420lqd; Tue, 23 Apr 2024 19:06:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWK5x9MzBaQ4LAYOt97Rv0gZaLUrw23aqmgwmwzVSZVusBpzWMyfgII920d7trNp80zMp0Rv4HlUFKZ2Tft/XalaF7GhepguMVxToe5QA== X-Google-Smtp-Source: AGHT+IEEWvLrNvKA1hu/2b9/6NGn42V8e2j9S7pm+DxnfkkJc8RzA/w8MO98f23mHxe7E5pSmWOy X-Received: by 2002:a17:906:7199:b0:a51:ddc6:f9c0 with SMTP id h25-20020a170906719900b00a51ddc6f9c0mr606516ejk.45.1713924383177; Tue, 23 Apr 2024 19:06:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713924383; cv=pass; d=google.com; s=arc-20160816; b=Gi7nHkPSEuvHuYkSe3P6rE+dkEb84alYqtSNsnVnYxr8Z6Ef/tq4qad02+dKjvG0Eo 9BjjykvKR+UAFTGCmQ1rw/st+OGo3ezmasduZzkBU9BNtiq91qtgg1Z0KvxxbOSqT6l2 J7xXxVruY2WxYz8fTfavrcSn0Cj0ImqU/VZDq7OMYx0r8027foiirQWZ9EU0RtEq1nEp 8sAUsQCv77DYMZSKWS+01k4xZYt7xvkBGIxBMvnV9HmFJ4b5l5+nvGgX+mazceJtZzMq uVxn/N+blSxREGCRRxzLyHW+oLYpYgO6Rf7Fyg147nuJIXiunZgVzaYmKO44cjOgKX7W v5Lw== 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; bh=3Edi09kWa8d1UnMEEekFB06GjrkdpnjUnRYC23Zj8P0=; fh=lPKFJvVb52pC2FZAsmTs3X0iL2A14rZznWkIdxXku7w=; b=Yz0Le8omreKGYyGjoLsP2S+UsKzz/ESKqCrJbu7vNbfmxpFfUAW2LGSlc4Pjf8XxlS 6fjkRdLaOlsjf6OnykDh3S3FsZ/tUUtnWQ7Nemp4vhF4evoU+46xnPWVxx0kp9cPhBFm /S21Udor5/CBteeJVifWopGvBTJxJFmFBfQDu5x4WEO1i+MMY0PWyHESQ6yRw6IjPJgx Li7Zo8ZUldRiO/7YNyrmeCtya6DwP6m12RoyNfbPQaEAro/urP6u53mzqBu8hxrQEiGm vdGVT4w3kPsuRMWEqMQlVL7JK8vjkGENzzjBU6KviFG0nYAh+xOkhBS6fbZuCwoqPbFb 1kQw==; 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-156120-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156120-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lr21-20020a170906fb9500b00a589484075dsi30256ejb.627.2024.04.23.19.06.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 19:06:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156120-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-156120-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156120-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 am.mirrors.kernel.org (Postfix) with ESMTPS id E36971F23C5C for ; Wed, 24 Apr 2024 02:06:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB27720DD3; Wed, 24 Apr 2024 02:05:23 +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 D88FE1D54B; Wed, 24 Apr 2024 02:05:19 +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=1713924323; cv=none; b=USKLLOHdN633SlgTpDDkF3jqrsm6LokVtRK6NWruKoW2FB3bSEisLqAbHecHOMYrtZLb49Vdbu8t3Ug1cRlLCgTBEovb63KI3zlnJbJ3cnx7o91BhQfaiEpCP8DdgQ8+B+z2vdbMICJdusJxa0DSxK6lO7TQ/x0oH5NzMytFTZk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713924323; c=relaxed/simple; bh=bwn4NKPDjBjaNuo3yEiLyY1cpnHyL8Uv30pKNbsM170=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GBfluh9oMVOfsOd09Z76ead5oFPOhjsx42gQD8tqT+Ashtj4VCs6geH8VZzcDnnPhJgzLbfUz1PJ/arj+fbsZoubcu0s3ZmtJc7z6TOHVyPEcL2uLsmw1JBlEz8/s8tY0iQ8kjVoE9CXQBEP/033jDJUJTSPnpXHh6MVWi1QU3Q= 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: 161efcb601df11ef9305a59a3cc225df-20240424 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:669ee238-3864-44f8-91ba-1556b251d4d0,IP:10, URL:0,TC:0,Content:0,EDM:0,RT:0,SF:-9,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:1 X-CID-INFO: VERSION:1.1.37,REQID:669ee238-3864-44f8-91ba-1556b251d4d0,IP:10,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:-9,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:1 X-CID-META: VersionHash:6f543d0,CLOUDID:ae00a2f80363ef3acd4c7fc3192d941f,BulkI D:240424100515AGH5VMPW,BulkQuantity:0,Recheck:0,SF:66|38|24|17|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_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI,TF_CID_SPAM_SNR X-UUID: 161efcb601df11ef9305a59a3cc225df-20240424 Received: from mail.kylinos.cn [(39.156.73.10)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA) with ESMTP id 1332634441; Wed, 24 Apr 2024 10:05:13 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 8A546E000EB9; Wed, 24 Apr 2024 10:05:12 +0800 (CST) X-ns-mid: postfix-662868D8-327764374 Received: from kernel.. (unknown [10.42.12.206]) by mail.kylinos.cn (NSMail) with ESMTPA id 3B3DCE000EBB; Wed, 24 Apr 2024 10:05:11 +0800 (CST) From: Kunwu Chan To: 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 Cc: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH bpf-next 4/4] selftests/bpf: Add a null pointer check for the serial_test_tp_attach_query Date: Wed, 24 Apr 2024 10:04:44 +0800 Message-Id: <20240424020444.2375773-5-chentao@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240424020444.2375773-1-chentao@kylinos.cn> References: <20240424020444.2375773-1-chentao@kylinos.cn> 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. Add the malloc failure checking to avoid possible null dereference. Signed-off-by: Kunwu Chan --- tools/testing/selftests/bpf/prog_tests/tp_attach_query.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c b/t= ools/testing/selftests/bpf/prog_tests/tp_attach_query.c index 655d69f0ff0b..302b25408a53 100644 --- a/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c +++ b/tools/testing/selftests/bpf/prog_tests/tp_attach_query.c @@ -39,6 +39,9 @@ void serial_test_tp_attach_query(void) attr.wakeup_events =3D 1; =20 query =3D malloc(sizeof(*query) + sizeof(__u32) * num_progs); + if (CHECK(!query, "malloc()", "error:%s\n", strerror(errno))) + return; + for (i =3D 0; i < num_progs; i++) { err =3D bpf_prog_test_load(file, BPF_PROG_TYPE_TRACEPOINT, &obj[i], &prog_fd[i]); --=20 2.40.1