[lvc-project] [PATCH] nfp: bpf: offload: Check prog before dereference

Artem Chernyshev artem.chernyshev at red-soft.ru
Wed Oct 18 17:52:44 MSK 2023


In nfp_net_bpf_offload() it is possible to dereference a
NULL pointer.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Artem Chernyshev <artem.chernyshev at red-soft.ru>
---
 drivers/net/ethernet/netronome/nfp/bpf/offload.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/bpf/offload.c b/drivers/net/ethernet/netronome/nfp/bpf/offload.c
index 9d97cd281f18..925862f7b7d6 100644
--- a/drivers/net/ethernet/netronome/nfp/bpf/offload.c
+++ b/drivers/net/ethernet/netronome/nfp/bpf/offload.c
@@ -598,8 +598,7 @@ int nfp_net_bpf_offload(struct nfp_net *nn, struct bpf_prog *prog,
 	if (old_prog && !prog)
 		return nfp_net_bpf_stop(nn);
 
-	err = nfp_net_bpf_load(nn, prog, extack);
-	if (err)
+	if (prog && (err = nfp_net_bpf_load(nn, prog, extack)))
 		return err;
 
 	if (!old_prog)
-- 
2.37.3




More information about the lvc-project mailing list