All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] sfc: Avoid NULL pointer dereference on systems without numa awareness
@ 2022-03-29 16:07 Martin Habets
  2022-03-30  9:28 ` Íñigo Huguet
  2022-03-30 19:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Martin Habets @ 2022-03-29 16:07 UTC (permalink / raw)
  To: kuba, pabeni, davem; +Cc: netdev, ihuguet, ecree.xilinx

On such systems cpumask_of_node() returns NULL, which bitmap
operations are not happy with.

Fixes: c265b569a45f ("sfc: default config to 1 channel/core in local NUMA node only")
Fixes: 09a99ab16c60 ("sfc: set affinity hints in local NUMA node only")
Signed-off-by: Martin Habets <habetsm.xilinx@gmail.com>
---
 drivers/net/ethernet/sfc/efx_channels.c |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/sfc/efx_channels.c b/drivers/net/ethernet/sfc/efx_channels.c
index d6fdcdc530ca..f9064532beb6 100644
--- a/drivers/net/ethernet/sfc/efx_channels.c
+++ b/drivers/net/ethernet/sfc/efx_channels.c
@@ -91,11 +91,9 @@ static unsigned int count_online_cores(struct efx_nic *efx, bool local_node)
 	}
 
 	cpumask_copy(filter_mask, cpu_online_mask);
-	if (local_node) {
-		int numa_node = pcibus_to_node(efx->pci_dev->bus);
-
-		cpumask_and(filter_mask, filter_mask, cpumask_of_node(numa_node));
-	}
+	if (local_node)
+		cpumask_and(filter_mask, filter_mask,
+			    cpumask_of_pcibus(efx->pci_dev->bus));
 
 	count = 0;
 	for_each_cpu(cpu, filter_mask) {
@@ -386,8 +384,7 @@ int efx_probe_interrupts(struct efx_nic *efx)
 #if defined(CONFIG_SMP)
 void efx_set_interrupt_affinity(struct efx_nic *efx)
 {
-	int numa_node = pcibus_to_node(efx->pci_dev->bus);
-	const struct cpumask *numa_mask = cpumask_of_node(numa_node);
+	const struct cpumask *numa_mask = cpumask_of_pcibus(efx->pci_dev->bus);
 	struct efx_channel *channel;
 	unsigned int cpu;
 


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] sfc: Avoid NULL pointer dereference on systems without numa awareness
  2022-03-29 16:07 [PATCH net] sfc: Avoid NULL pointer dereference on systems without numa awareness Martin Habets
@ 2022-03-30  9:28 ` Íñigo Huguet
  2022-03-30 19:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Íñigo Huguet @ 2022-03-30  9:28 UTC (permalink / raw)
  To: Martin Habets
  Cc: Jakub Kicinski, pabeni, David S. Miller, netdev, Edward Cree

On Tue, Mar 29, 2022 at 6:08 PM Martin Habets <habetsm.xilinx@gmail.com> wrote:
>
> On such systems cpumask_of_node() returns NULL, which bitmap
> operations are not happy with.
>
> Fixes: c265b569a45f ("sfc: default config to 1 channel/core in local NUMA node only")
> Fixes: 09a99ab16c60 ("sfc: set affinity hints in local NUMA node only")
> Signed-off-by: Martin Habets <habetsm.xilinx@gmail.com>
> ---
>  drivers/net/ethernet/sfc/efx_channels.c |   11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/sfc/efx_channels.c b/drivers/net/ethernet/sfc/efx_channels.c
> index d6fdcdc530ca..f9064532beb6 100644
> --- a/drivers/net/ethernet/sfc/efx_channels.c
> +++ b/drivers/net/ethernet/sfc/efx_channels.c
> @@ -91,11 +91,9 @@ static unsigned int count_online_cores(struct efx_nic *efx, bool local_node)
>         }
>
>         cpumask_copy(filter_mask, cpu_online_mask);
> -       if (local_node) {
> -               int numa_node = pcibus_to_node(efx->pci_dev->bus);
> -
> -               cpumask_and(filter_mask, filter_mask, cpumask_of_node(numa_node));
> -       }
> +       if (local_node)
> +               cpumask_and(filter_mask, filter_mask,
> +                           cpumask_of_pcibus(efx->pci_dev->bus));
>
>         count = 0;
>         for_each_cpu(cpu, filter_mask) {
> @@ -386,8 +384,7 @@ int efx_probe_interrupts(struct efx_nic *efx)
>  #if defined(CONFIG_SMP)
>  void efx_set_interrupt_affinity(struct efx_nic *efx)
>  {
> -       int numa_node = pcibus_to_node(efx->pci_dev->bus);
> -       const struct cpumask *numa_mask = cpumask_of_node(numa_node);
> +       const struct cpumask *numa_mask = cpumask_of_pcibus(efx->pci_dev->bus);
>         struct efx_channel *channel;
>         unsigned int cpu;
>
>

Reviewed-by: Íñigo Huguet <ihuguet@redhat.com>

-- 
Íñigo Huguet


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] sfc: Avoid NULL pointer dereference on systems without numa awareness
  2022-03-29 16:07 [PATCH net] sfc: Avoid NULL pointer dereference on systems without numa awareness Martin Habets
  2022-03-30  9:28 ` Íñigo Huguet
@ 2022-03-30 19:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-30 19:30 UTC (permalink / raw)
  To: Martin Habets; +Cc: kuba, pabeni, davem, netdev, ihuguet, ecree.xilinx

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 29 Mar 2022 17:07:49 +0100 you wrote:
> On such systems cpumask_of_node() returns NULL, which bitmap
> operations are not happy with.
> 
> Fixes: c265b569a45f ("sfc: default config to 1 channel/core in local NUMA node only")
> Fixes: 09a99ab16c60 ("sfc: set affinity hints in local NUMA node only")
> Signed-off-by: Martin Habets <habetsm.xilinx@gmail.com>
> 
> [...]

Here is the summary with links:
  - [net] sfc: Avoid NULL pointer dereference on systems without numa awareness
    https://git.kernel.org/netdev/net/c/c9ad266bbef5

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-30 19:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 16:07 [PATCH net] sfc: Avoid NULL pointer dereference on systems without numa awareness Martin Habets
2022-03-30  9:28 ` Íñigo Huguet
2022-03-30 19:30 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.