]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
nfp: flower: handle acti_netdevs allocation failure
authorDuoming Zhou <duoming@zju.edu.cn>
Fri, 8 Mar 2024 14:25:40 +0000 (22:25 +0800)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:21:54 +0000 (18:21 -0400)
[ Upstream commit 84e95149bd341705f0eca6a7fcb955c548805002 ]

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: bb9a8d031140 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/netronome/nfp/flower/lag_conf.c

index 63907aeb3884e51c515e76e3ff4aaa96bfa329a1..3167f9675ae0f2e860032cae1b17ece2e0a31877 100644 (file)
@@ -308,6 +308,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