From nobody Fri Oct 3 00:51:30 2025 Received: from out-186.mta0.migadu.com (out-186.mta0.migadu.com [91.218.175.186]) (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 AE7DB1A8F97; Tue, 9 Sep 2025 02:31:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.186 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757385114; cv=none; b=jcx8rnXvubMLgG8GXEhPYY7NA5SX2TfOSaVtB3uNzPqMdYel3roWr2ieeUQs/huK8fczBlvF9eTvDHmk9MlzVHO5zY3XmfUZv8UCJ9JFS+pgVKzIIPa0GzDylgKtfByK0wR3E+tgTkRgMuamumZD6BqE3EyoK6fJPIdTPLE3MWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757385114; c=relaxed/simple; bh=voIwO7aB55DFEwbmZ9+P0CiskzmhgCldk/xu8wyh4rc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=o72KvHscDSy5hThy6EAXkr7p8DthSUYCeC+n7QShHdAY3w3pjAVlFLZ9p63PDXwa84JyWMQQH/Y6FDpH9nAxvcYKIpE59EMZamHiZNOvGg1OKRMMdnypflrpwIHr+EQq1EiTUeqahpbZ4W/MZs3mhSNO7gauWdZnbwFJsnEcU2w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=a37qJk+G; arc=none smtp.client-ip=91.218.175.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="a37qJk+G" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1757385109; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=WweqMmyOHEemYumtjGpzECw+a4p1s0bPOHN7VW0FAYQ=; b=a37qJk+GX00b+p+R4Pc8WBlLLIJbAZwzFVV9VOenmKfhjH/CkZw2JEW0lPE8OVuKlVM/g2 PVjtltxw5Z1LHp4IdCI1x6TPgxjGh/sxkzQJMj3ymqBcFdf1rZwQtzp0KjG24zPnNr6Q11 9xCnlrrRkEZX96CrsgDMN4XhIDpCQRM= From: Jiayuan Chen To: jiayuan.chen@linux.dev Cc: Dan Carpenter , Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Jiapeng Chong , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] selftests/bpf: Fix incorrect array size calculation Date: Tue, 9 Sep 2025 10:31:12 +0800 Message-ID: <20250909023130.28325-1-jiayuan.chen@linux.dev> 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 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Fix it by using ARRAY_SIZE. Signed-off-by: Jiayuan Chen Reported-by: Dan Carpenter Closes: https://lore.kernel.org/bpf/aLqfWuRR9R_KTe5e@stanley.mountain/ --- tools/testing/selftests/bpf/benchs/bench_sockmap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/benchs/bench_sockmap.c b/tools/tes= ting/selftests/bpf/benchs/bench_sockmap.c index 8ebf563a67a2..cfc072aa7fff 100644 --- a/tools/testing/selftests/bpf/benchs/bench_sockmap.c +++ b/tools/testing/selftests/bpf/benchs/bench_sockmap.c @@ -10,6 +10,7 @@ #include #include "bench.h" #include "bench_sockmap_prog.skel.h" +#include "bpf_util.h" =20 #define FILE_SIZE (128 * 1024) #define DATA_REPEAT_SIZE 10 @@ -124,8 +125,8 @@ static void bench_sockmap_prog_destroy(void) { int i; =20 - for (i =3D 0; i < sizeof(ctx.fds); i++) { - if (ctx.fds[0] > 0) + for (i =3D 0; i < ARRAY_SIZE(ctx.fds); i++) { + if (ctx.fds[i] > 0) close(ctx.fds[i]); } =20 base-commit: 60ef54156148ffaa719845bc5b1fdeafa67763fc --=20 2.43.0