From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 38594443A80; Tue, 21 Jul 2026 22:29:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784672948; cv=none; b=cVqGT++H+XkgsTdHqUPL3soX9zu19Uwtk/2aMSPOAjnlka7cpuoLt1U9RL/DbvRUswNdSo7KdvQOCzMTlMaz1ZNHs1FiXc+c9/9LOLdeKZCF1cdt8Opa9LWfFjwTapjB5KwUbyeJdkmPylwQUPC5FpRs5HQKJFOWG/HSh8ajnCo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784672948; c=relaxed/simple; bh=tQtfP4p8V258448qsr7BdiaCO7roERheyLjvZ0CaFtA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SHyWj+stWxLJeJB9D30gr8lnU3crkt9hx4QJlZAmGcu9rKPmB4MkIZUxVqEj4aiJ/rx70W2TWQrEAENUBOoHELWqFrFNYsg1XUzFBH+GUw3Ken058VbVMxhRI1+Ps4wz2+3zGrOjqLu630kXOSi3evK/TQV9810K4hD/XLOY8r4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uV95oMt8; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="uV95oMt8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62E7F1F000E9; Tue, 21 Jul 2026 22:29:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784672946; bh=qgEvp9wmwRweyILJP2mQ+g5YmP44hM5WvQZ3ArbL0cc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uV95oMt8XzzTpCh6c3dHBvLtuVjVynaSDxjGYj/TgxMNf4M8pGr0ADje1OrWJZZ2I k77UEDc3sOuLtq1d6of8BU0+yMXgp2mIyUNiE4D6z2I2H/t6oSVU7UhbqkU5MW70P0 zrpIb7Sog3kDcuLT7ubCdbimhPZ6sWItGBzZ7KW4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Qianfeng Rong , Florian Westphal , Sasha Levin Subject: [PATCH 5.15 774/843] netfilter: ebtables: Use vmalloc_array() to improve code Date: Tue, 21 Jul 2026 17:26:49 +0200 Message-ID: <20260721152423.466797929@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152405.946368001@linuxfoundation.org> References: <20260721152405.946368001@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Qianfeng Rong [ Upstream commit 46015e6b3ea75297b28d4806564f3f692cf11861 ] Remove array_size() calls and replace vmalloc() with vmalloc_array() to simplify the code. vmalloc_array() is also optimized better, uses fewer instructions, and handles overflow more concisely[1]. [1]: https://lore.kernel.org/lkml/abc66ec5-85a4-47e1-9759-2f60ab111971@vivo.com/ Signed-off-by: Qianfeng Rong Signed-off-by: Florian Westphal Stable-dep-of: cbfe53599eeb ("netfilter: ebtables: zero chainstack array") Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/bridge/netfilter/ebtables.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -923,8 +923,8 @@ static int translate_table(struct net *n * if an error occurs */ newinfo->chainstack = - vmalloc(array_size(nr_cpu_ids, - sizeof(*(newinfo->chainstack)))); + vmalloc_array(nr_cpu_ids, + sizeof(*(newinfo->chainstack))); if (!newinfo->chainstack) return -ENOMEM; for_each_possible_cpu(i) { @@ -941,7 +941,7 @@ static int translate_table(struct net *n } } - cl_s = vmalloc(array_size(udc_cnt, sizeof(*cl_s))); + cl_s = vmalloc_array(udc_cnt, sizeof(*cl_s)); if (!cl_s) return -ENOMEM; i = 0; /* the i'th udc */ @@ -1021,8 +1021,8 @@ static int do_replace_finish(struct net * the check on the size is done later, when we have the lock */ if (repl->num_counters) { - unsigned long size = repl->num_counters * sizeof(*counterstmp); - counterstmp = vmalloc(size); + counterstmp = vmalloc_array(repl->num_counters, + sizeof(*counterstmp)); if (!counterstmp) return -ENOMEM; } @@ -1389,7 +1389,7 @@ static int do_update_counters(struct net if (num_counters == 0) return -EINVAL; - tmp = vmalloc(array_size(num_counters, sizeof(*tmp))); + tmp = vmalloc_array(num_counters, sizeof(*tmp)); if (!tmp) return -ENOMEM; @@ -1530,7 +1530,7 @@ static int copy_counters_to_user(struct if (num_counters != nentries) return -EINVAL; - counterstmp = vmalloc(array_size(nentries, sizeof(*counterstmp))); + counterstmp = vmalloc_array(nentries, sizeof(*counterstmp)); if (!counterstmp) return -ENOMEM;