Remove array_size() calls and replace vmalloc() with vmalloc_array() to
simplify the code and maintain consistency with existing kmalloc_array()
usage.
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 2 +-
drivers/net/ethernet/intel/igb/igb_ethtool.c | 8 ++++----
drivers/net/ethernet/intel/igc/igc_ethtool.c | 8 ++++----
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 2 +-
drivers/net/ethernet/intel/ixgbevf/ethtool.c | 6 +++---
5 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
index 1954a04460d1..bf2029144c1d 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
@@ -560,7 +560,7 @@ static int fm10k_set_ringparam(struct net_device *netdev,
/* allocate temporary buffer to store rings in */
i = max_t(int, interface->num_tx_queues, interface->num_rx_queues);
- temp_ring = vmalloc(array_size(i, sizeof(struct fm10k_ring)));
+ temp_ring = vmalloc_array(i, sizeof(struct fm10k_ring));
if (!temp_ring) {
err = -ENOMEM;
diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
index 92ef33459aec..51d5cb6599ed 100644
--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
@@ -920,11 +920,11 @@ static int igb_set_ringparam(struct net_device *netdev,
}
if (adapter->num_tx_queues > adapter->num_rx_queues)
- temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
- adapter->num_tx_queues));
+ temp_ring = vmalloc_array(adapter->num_tx_queues,
+ sizeof(struct igb_ring));
else
- temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
- adapter->num_rx_queues));
+ temp_ring = vmalloc_array(adapter->num_rx_queues,
+ sizeof(struct igb_ring));
if (!temp_ring) {
err = -ENOMEM;
diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c
index ecb35b693ce5..f3e7218ba6f3 100644
--- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
@@ -627,11 +627,11 @@ igc_ethtool_set_ringparam(struct net_device *netdev,
}
if (adapter->num_tx_queues > adapter->num_rx_queues)
- temp_ring = vmalloc(array_size(sizeof(struct igc_ring),
- adapter->num_tx_queues));
+ temp_ring = vmalloc_array(adapter->num_tx_queues,
+ sizeof(struct igc_ring));
else
- temp_ring = vmalloc(array_size(sizeof(struct igc_ring),
- adapter->num_rx_queues));
+ temp_ring = vmalloc_array(adapter->num_rx_queues,
+ sizeof(struct igc_ring));
if (!temp_ring) {
err = -ENOMEM;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 25c3a09ad7f1..2c5d774f1ec1 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -1278,7 +1278,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
/* allocate temporary buffer to store rings in */
i = max_t(int, adapter->num_tx_queues + adapter->num_xdp_queues,
adapter->num_rx_queues);
- temp_ring = vmalloc(array_size(i, sizeof(struct ixgbe_ring)));
+ temp_ring = vmalloc_array(i, sizeof(struct ixgbe_ring));
if (!temp_ring) {
err = -ENOMEM;
diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
index 7ac53171b041..bebad564188e 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
@@ -276,9 +276,9 @@ static int ixgbevf_set_ringparam(struct net_device *netdev,
}
if (new_tx_count != adapter->tx_ring_count) {
- tx_ring = vmalloc(array_size(sizeof(*tx_ring),
- adapter->num_tx_queues +
- adapter->num_xdp_queues));
+ tx_ring = vmalloc_array(adapter->num_tx_queues +
+ adapter->num_xdp_queues,
+ sizeof(*tx_ring));
if (!tx_ring) {
err = -ENOMEM;
goto clear_reset;
--
2.34.1
On Tue, 12 Aug 2025 21:32:14 +0800 Qianfeng Rong wrote: > Subject: [PATCH 1/5] ethtool: use vmalloc_array() to simplify code ethtool: would make sense for patches which touch net/ethtool. Please use eth: intel: as the subject prefix.
在 2025/8/13 4:49, Jakub Kicinski 写道: > On Tue, 12 Aug 2025 21:32:14 +0800 Qianfeng Rong wrote: >> Subject: [PATCH 1/5] ethtool: use vmalloc_array() to simplify code > ethtool: > > would make sense for patches which touch net/ethtool. > Please use > > eth: intel: > > as the subject prefix. Got it. Will do in the next version. Best regards, Qianfeng
Dear Qianfeng,
Thank you for your patch.
Am 12.08.25 um 15:32 schrieb Qianfeng Rong:
> Remove array_size() calls and replace vmalloc() with vmalloc_array() to
> simplify the code and maintain consistency with existing kmalloc_array()
> usage.
You could build it without and with your patch and look if the assembler
code changes.
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
> ---
> drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 2 +-
> drivers/net/ethernet/intel/igb/igb_ethtool.c | 8 ++++----
> drivers/net/ethernet/intel/igc/igc_ethtool.c | 8 ++++----
> drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 2 +-
> drivers/net/ethernet/intel/ixgbevf/ethtool.c | 6 +++---
> 5 files changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> index 1954a04460d1..bf2029144c1d 100644
> --- a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> +++ b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> @@ -560,7 +560,7 @@ static int fm10k_set_ringparam(struct net_device *netdev,
>
> /* allocate temporary buffer to store rings in */
> i = max_t(int, interface->num_tx_queues, interface->num_rx_queues);
> - temp_ring = vmalloc(array_size(i, sizeof(struct fm10k_ring)));
> + temp_ring = vmalloc_array(i, sizeof(struct fm10k_ring));
>
> if (!temp_ring) {
> err = -ENOMEM;
> diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
> index 92ef33459aec..51d5cb6599ed 100644
> --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
> +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
> @@ -920,11 +920,11 @@ static int igb_set_ringparam(struct net_device *netdev,
> }
>
> if (adapter->num_tx_queues > adapter->num_rx_queues)
> - temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
> - adapter->num_tx_queues));
> + temp_ring = vmalloc_array(adapter->num_tx_queues,
> + sizeof(struct igb_ring));
> else
> - temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
> - adapter->num_rx_queues));
> + temp_ring = vmalloc_array(adapter->num_rx_queues,
> + sizeof(struct igb_ring));
>
> if (!temp_ring) {
> err = -ENOMEM;
> diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c
> index ecb35b693ce5..f3e7218ba6f3 100644
> --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
> +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
> @@ -627,11 +627,11 @@ igc_ethtool_set_ringparam(struct net_device *netdev,
> }
>
> if (adapter->num_tx_queues > adapter->num_rx_queues)
> - temp_ring = vmalloc(array_size(sizeof(struct igc_ring),
> - adapter->num_tx_queues));
> + temp_ring = vmalloc_array(adapter->num_tx_queues,
> + sizeof(struct igc_ring));
> else
> - temp_ring = vmalloc(array_size(sizeof(struct igc_ring),
> - adapter->num_rx_queues));
> + temp_ring = vmalloc_array(adapter->num_rx_queues,
> + sizeof(struct igc_ring));
>
> if (!temp_ring) {
> err = -ENOMEM;
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> index 25c3a09ad7f1..2c5d774f1ec1 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> @@ -1278,7 +1278,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
> /* allocate temporary buffer to store rings in */
> i = max_t(int, adapter->num_tx_queues + adapter->num_xdp_queues,
> adapter->num_rx_queues);
> - temp_ring = vmalloc(array_size(i, sizeof(struct ixgbe_ring)));
> + temp_ring = vmalloc_array(i, sizeof(struct ixgbe_ring));
>
> if (!temp_ring) {
> err = -ENOMEM;
> diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
> index 7ac53171b041..bebad564188e 100644
> --- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c
> +++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
> @@ -276,9 +276,9 @@ static int ixgbevf_set_ringparam(struct net_device *netdev,
> }
>
> if (new_tx_count != adapter->tx_ring_count) {
> - tx_ring = vmalloc(array_size(sizeof(*tx_ring),
> - adapter->num_tx_queues +
> - adapter->num_xdp_queues));
> + tx_ring = vmalloc_array(adapter->num_tx_queues +
> + adapter->num_xdp_queues,
> + sizeof(*tx_ring));
> if (!tx_ring) {
> err = -ENOMEM;
> goto clear_reset;
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Kind regards,
Paul
在 2025/8/13 0:34, Paul Menzel 写道:
> [You don't often get email from pmenzel@molgen.mpg.de. Learn why this
> is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Dear Qianfeng,
>
>
> Thank you for your patch.
>
> Am 12.08.25 um 15:32 schrieb Qianfeng Rong:
>> Remove array_size() calls and replace vmalloc() with vmalloc_array() to
>> simplify the code and maintain consistency with existing kmalloc_array()
>> usage.
>
> You could build it without and with your patch and look if the assembler
> code changes.
>
Very good point, the following experiment was done:
//before apply patch:
objdump -dSl --prefix-addresses fm10k_ethtool.o > original.dis
//after apply patch:
objdump -dSl --prefix-addresses fm10k_ethtool.o > patched.dis
diff -u original.dis patched.dis | diffstat
patched.dis | 1578 ... 1 file changed, 785 insertions(+), 793 deletions(-)
From the above results, we can see that the assembly instructions are
reduced after applying the patch.
#define array_size(a, b) size_mul(a, b)
static inline size_t __must_check size_mul(size_t factor1, size_t factor2)
{
size_t bytes;
if (check_mul_overflow(factor1, factor2, &bytes))
return SIZE_MAX;
return bytes;
}
void *__vmalloc_array_noprof(size_t n, size_t size, gfp_t flags)
{
size_t bytes;
if (unlikely(check_mul_overflow(n, size, &bytes)))
return NULL;
return __vmalloc_noprof(bytes, flags);
}
And from the code, array_size() will return SIZE_MAX after detecting
overflow. SIZE_MAX is passed to vmalloc for available memory
verification before exiting and returning NULL. vmalloc_array()
will directly return NULL after detecting overflow.
Best regards,
Qianfeng
> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
>
>
> Kind regards,
>
> Paul
Dear Quianfeng,
Thank you very much for your reply.
Am 14.08.25 um 06:05 schrieb Qianfeng Rong:
>
> 在 2025/8/13 0:34, Paul Menzel 写道:
[…]
>> Am 12.08.25 um 15:32 schrieb Qianfeng Rong:
>>> Remove array_size() calls and replace vmalloc() with vmalloc_array() to
>>> simplify the code and maintain consistency with existing kmalloc_array()
>>> usage.
>>
>> You could build it without and with your patch and look if the assembler
>> code changes.
>
> Very good point, the following experiment was done:
> //before apply patch:
> objdump -dSl --prefix-addresses fm10k_ethtool.o > original.dis
>
> //after apply patch:
> objdump -dSl --prefix-addresses fm10k_ethtool.o > patched.dis
>
> diff -u original.dis patched.dis | diffstat
> patched.dis | 1578 ... 1 file changed, 785 insertions(+), 793 deletions(-)
>
> From the above results, we can see that the assembly instructions are
> reduced after applying the patch.
>
>
> #define array_size(a, b) size_mul(a, b)
>
> static inline size_t __must_check size_mul(size_t factor1, size_t factor2)
> {
> size_t bytes;
>
> if (check_mul_overflow(factor1, factor2, &bytes))
> return SIZE_MAX;
>
> return bytes;
> }
>
> void *__vmalloc_array_noprof(size_t n, size_t size, gfp_t flags)
> {
> size_t bytes;
>
> if (unlikely(check_mul_overflow(n, size, &bytes)))
> return NULL;
> return __vmalloc_noprof(bytes, flags);
> }
>
> And from the code, array_size() will return SIZE_MAX after detecting
> overflow. SIZE_MAX is passed to vmalloc for available memory
> verification before exiting and returning NULL. vmalloc_array()
> will directly return NULL after detecting overflow.
Awesome! Thank you for digging that up. Maybe something to add to the
commit message. Maybe something like:
`vmalloc_array()` is also optimized better, resulting in less
instructions being used, which can be verified with:
objdump -dSl --prefix-addresses <changed module>.o
>> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Kind regards,
Paul
在 2025/8/14 14:28, Paul Menzel 写道:
> [You don't often get email from pmenzel@molgen.mpg.de. Learn why this
> is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Dear Quianfeng,
>
>
> Thank you very much for your reply.
>
> Am 14.08.25 um 06:05 schrieb Qianfeng Rong:
>>
>> 在 2025/8/13 0:34, Paul Menzel 写道:
>
> […]
>
>>> Am 12.08.25 um 15:32 schrieb Qianfeng Rong:
>>>> Remove array_size() calls and replace vmalloc() with
>>>> vmalloc_array() to
>>>> simplify the code and maintain consistency with existing
>>>> kmalloc_array()
>>>> usage.
>>>
>>> You could build it without and with your patch and look if the
>>> assembler
>>> code changes.
>>
>> Very good point, the following experiment was done:
>> //before apply patch:
>> objdump -dSl --prefix-addresses fm10k_ethtool.o > original.dis
>>
>> //after apply patch:
>> objdump -dSl --prefix-addresses fm10k_ethtool.o > patched.dis
>>
>> diff -u original.dis patched.dis | diffstat
>> patched.dis | 1578 ... 1 file changed, 785 insertions(+), 793
>> deletions(-)
>>
>> From the above results, we can see that the assembly instructions are
>> reduced after applying the patch.
>>
>>
>> #define array_size(a, b) size_mul(a, b)
>>
>> static inline size_t __must_check size_mul(size_t factor1, size_t
>> factor2)
>> {
>> size_t bytes;
>>
>> if (check_mul_overflow(factor1, factor2, &bytes))
>> return SIZE_MAX;
>>
>> return bytes;
>> }
>>
>> void *__vmalloc_array_noprof(size_t n, size_t size, gfp_t flags)
>> {
>> size_t bytes;
>>
>> if (unlikely(check_mul_overflow(n, size, &bytes)))
>> return NULL;
>> return __vmalloc_noprof(bytes, flags);
>> }
>>
>> And from the code, array_size() will return SIZE_MAX after detecting
>> overflow. SIZE_MAX is passed to vmalloc for available memory
>> verification before exiting and returning NULL. vmalloc_array()
>> will directly return NULL after detecting overflow.
>
> Awesome! Thank you for digging that up. Maybe something to add to the
> commit message. Maybe something like:
>
> `vmalloc_array()` is also optimized better, resulting in less
> instructions being used, which can be verified with:
>
> objdump -dSl --prefix-addresses <changed module>.o
Ok,I'll release v2 later.
>
>>> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
>
>
> Kind regards,
>
> Paul
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Qianfeng Rong
> Sent: Tuesday, August 12, 2025 3:32 PM
> To: Nguyen, Anthony L <anthony.l.nguyen@intel.com>; Kitszel,
> Przemyslaw <przemyslaw.kitszel@intel.com>; Andrew Lunn
> <andrew+netdev@lunn.ch>; David S. Miller <davem@davemloft.net>; Eric
> Dumazet <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo
> Abeni <pabeni@redhat.com>; Alexei Starovoitov <ast@kernel.org>; Daniel
> Borkmann <daniel@iogearbox.net>; Jesper Dangaard Brouer
> <hawk@kernel.org>; John Fastabend <john.fastabend@gmail.com>;
> Stanislav Fomichev <sdf@fomichev.me>; moderated list:INTEL ETHERNET
> DRIVERS <intel-wired-lan@lists.osuosl.org>; open list:NETWORKING
> DRIVERS <netdev@vger.kernel.org>; open list <linux-
> kernel@vger.kernel.org>; open list:XDP (eXpress Data
> Path):Keyword:(?:\b|_)xdp(?:\b|_) <bpf@vger.kernel.org>
> Cc: Qianfeng Rong <rongqianfeng@vivo.com>
> Subject: [Intel-wired-lan] [PATCH 1/5] ethtool: use vmalloc_array() to
> simplify code
>
> Remove array_size() calls and replace vmalloc() with vmalloc_array()
> to simplify the code and maintain consistency with existing
> kmalloc_array() usage.
>
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> ---
> drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | 2 +-
> drivers/net/ethernet/intel/igb/igb_ethtool.c | 8 ++++----
> drivers/net/ethernet/intel/igc/igc_ethtool.c | 8 ++++----
> drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 2 +-
> drivers/net/ethernet/intel/ixgbevf/ethtool.c | 6 +++---
> 5 files changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> index 1954a04460d1..bf2029144c1d 100644
> --- a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> +++ b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> @@ -560,7 +560,7 @@ static int fm10k_set_ringparam(struct net_device
> *netdev,
>
> /* allocate temporary buffer to store rings in */
> i = max_t(int, interface->num_tx_queues, interface-
> >num_rx_queues);
> - temp_ring = vmalloc(array_size(i, sizeof(struct fm10k_ring)));
> + temp_ring = vmalloc_array(i, sizeof(struct fm10k_ring));
>
> if (!temp_ring) {
> err = -ENOMEM;
> diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c
> b/drivers/net/ethernet/intel/igb/igb_ethtool.c
> index 92ef33459aec..51d5cb6599ed 100644
> --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
> +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
> @@ -920,11 +920,11 @@ static int igb_set_ringparam(struct net_device
> *netdev,
> }
>
> if (adapter->num_tx_queues > adapter->num_rx_queues)
> - temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
> - adapter->num_tx_queues));
> + temp_ring = vmalloc_array(adapter->num_tx_queues,
> + sizeof(struct igb_ring));
> else
> - temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
> - adapter->num_rx_queues));
> + temp_ring = vmalloc_array(adapter->num_rx_queues,
> + sizeof(struct igb_ring));
>
> if (!temp_ring) {
> err = -ENOMEM;
> diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c
> b/drivers/net/ethernet/intel/igc/igc_ethtool.c
> index ecb35b693ce5..f3e7218ba6f3 100644
> --- a/drivers/net/ethernet/intel/igc/igc_ethtool.c
> +++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c
> @@ -627,11 +627,11 @@ igc_ethtool_set_ringparam(struct net_device
> *netdev,
> }
>
> if (adapter->num_tx_queues > adapter->num_rx_queues)
> - temp_ring = vmalloc(array_size(sizeof(struct igc_ring),
> - adapter->num_tx_queues));
> + temp_ring = vmalloc_array(adapter->num_tx_queues,
> + sizeof(struct igc_ring));
> else
> - temp_ring = vmalloc(array_size(sizeof(struct igc_ring),
> - adapter->num_rx_queues));
> + temp_ring = vmalloc_array(adapter->num_rx_queues,
> + sizeof(struct igc_ring));
>
> if (!temp_ring) {
> err = -ENOMEM;
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> index 25c3a09ad7f1..2c5d774f1ec1 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> @@ -1278,7 +1278,7 @@ static int ixgbe_set_ringparam(struct net_device
> *netdev,
> /* allocate temporary buffer to store rings in */
> i = max_t(int, adapter->num_tx_queues + adapter-
> >num_xdp_queues,
> adapter->num_rx_queues);
> - temp_ring = vmalloc(array_size(i, sizeof(struct ixgbe_ring)));
> + temp_ring = vmalloc_array(i, sizeof(struct ixgbe_ring));
>
> if (!temp_ring) {
> err = -ENOMEM;
> diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c
> b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
> index 7ac53171b041..bebad564188e 100644
> --- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c
> +++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
> @@ -276,9 +276,9 @@ static int ixgbevf_set_ringparam(struct net_device
> *netdev,
> }
>
> if (new_tx_count != adapter->tx_ring_count) {
> - tx_ring = vmalloc(array_size(sizeof(*tx_ring),
> - adapter->num_tx_queues +
> - adapter->num_xdp_queues));
> + tx_ring = vmalloc_array(adapter->num_tx_queues +
> + adapter->num_xdp_queues,
> + sizeof(*tx_ring));
> if (!tx_ring) {
> err = -ENOMEM;
> goto clear_reset;
> --
> 2.34.1
© 2016 - 2026 Red Hat, Inc.