diff mbox series

[net] sfc: Avoid NULL pointer dereference on systems without numa awareness

Message ID 164857006953.8140.3265568858101821256.stgit@palantir17.mph.net (mailing list archive)
State Accepted
Commit c9ad266bbef58dcbb6e74a6dbc5c4c2ed166e9b7
Delegated to: Netdev Maintainers
Headers show
Series [net] sfc: Avoid NULL pointer dereference on systems without numa awareness | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 23 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Martin Habets March 29, 2022, 4:07 p.m. UTC
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(-)

Comments

Íñigo Huguet March 30, 2022, 9:28 a.m. UTC | #1
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>
patchwork-bot+netdevbpf@kernel.org March 30, 2022, 7:30 p.m. UTC | #2
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!
diff mbox series

Patch

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;