Skip to content

Commit

Permalink
nfp: flower: handle acti_netdevs allocation failure
Browse files Browse the repository at this point in the history
The kmalloc_array() in nfp_fl_lag_do_work() will return null, if
the physical memory has run out. As a result, if we dereference
the acti_netdevs, the null pointer dereference bugs will happen.

This patch adds a check to judge whether allocation failure occurs.
If it happens, the delayed work will be rescheduled and try again.

Fixes: bb9a8d0 ("nfp: flower: monitor and offload LAG groups")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Reviewed-by: Louis Peens <louis.peens@corigine.com>
Link: https://lore.kernel.org/r/20240308142540.9674-1-duoming@zju.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Duoming Zhou authored and Jakub Kicinski committed Mar 11, 2024
1 parent 46590b5 commit 84e9514
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/net/ethernet/netronome/nfp/flower/lag_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ static void nfp_fl_lag_do_work(struct work_struct *work)

acti_netdevs = kmalloc_array(entry->slave_cnt,
sizeof(*acti_netdevs), GFP_KERNEL);
if (!acti_netdevs) {
schedule_delayed_work(&lag->work,
NFP_FL_LAG_DELAY);
continue;
}

/* Include sanity check in the loop. It may be that a bond has
* changed between processing the last notification and the
Expand Down

0 comments on commit 84e9514

Please sign in to comment.