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 9342D44AB62; Tue, 21 Jul 2026 21:51:22 +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=1784670684; cv=none; b=GL3C1qQedfAEeXoErDVJl5oSB83kU67uB/yN1Lx6jWJ9R7tOo+e5XzCVwmK8bgszBwY0jK1W96j6YKb0/xqS61pAJ8mX9FcM3jzkMj7bi2ngJz6VZv9g4I866nvVMshAZLQwyf1cEOkophpjOT3/ni/leXr+Fgxgu1uwcJ4sDMk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784670684; c=relaxed/simple; bh=z+9IyxhuIc2nus9vU46+4drUQpY7zxLQHkPYQz91Juo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oEKSG5BmlkugFbG9eVXRwWHxQNWh0+8ydYi2eMj39eyEDHj9YEy5YiKM3JyYXq4+X+jAdVbKSQ+0rBCEP6hRWlNjj/wxWNVhWBKddJbBohzJlMDqEmXpavNYnMIoY5Gyh1oIJ5sauKov7BmiAv74Zif4BA/njxiZ5TG05er0y1w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HEqmuI3X; 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="HEqmuI3X" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 042941F000E9; Tue, 21 Jul 2026 21:51:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784670682; bh=/oXbCdbfcALnqZfAHs0p9534CdRg12VBUflRU2BQ4Go=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HEqmuI3X2A66yYVO4xiJk1MR2zjLoOCUjWjztJm4xKcDkV+iw9Ue46SWL+kvDTHcE boeYSja03M1WIUP9ieEgYbTcOn+mqc1cOqS7IyhxhKYn7w5YtxD2Q0HUCedlXDC3T6 g3PlIY4gByccbnQNR3vgrDByyO19oQeqWBRx83Qc= 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 6.1 0982/1067] netfilter: ebtables: Use vmalloc_array() to improve code Date: Tue, 21 Jul 2026 17:26:23 +0200 Message-ID: <20260721152446.520818481@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152424.521567757@linuxfoundation.org> References: <20260721152424.521567757@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 6.1-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; @@ -1531,7 +1531,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;