From 8741fe2dc36da952db7e3514456cc473414c10c4 Mon Sep 17 00:00:00 2001 From: ycchen Date: Tue, 29 Oct 2024 10:14:05 +0800 Subject: [PATCH 1/2] add null check --- src/genl/genl_pdr.c | 4 +++- src/gtpu/encap.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/genl/genl_pdr.c b/src/genl/genl_pdr.c index 971be16..10e8036 100644 --- a/src/genl/genl_pdr.c +++ b/src/genl/genl_pdr.c @@ -473,7 +473,9 @@ static int pdr_fill(struct pdr *pdr, struct gtp5g_dev *gtp, struct genl_info *in pdr->af = AF_INET; far = find_far_by_id(gtp, pdr->seid, *pdr->far_id); - rcu_assign_pointer(pdr->far, far); + if (far) { + rcu_assign_pointer(pdr->far, far); + } err = far_set_pdr(pdr, gtp); if (err) diff --git a/src/gtpu/encap.c b/src/gtpu/encap.c index 54e143d..7480b33 100644 --- a/src/gtpu/encap.c +++ b/src/gtpu/encap.c @@ -617,6 +617,8 @@ int update_urr_counter_and_send_report(struct pdr *pdr, struct far *far, u64 vol for (i = 0; i < pdr->urr_num; i++) { urr = find_urr_by_id(gtp, pdr->seid, pdr->urr_ids[i]); + if (!urr) + continue; mnop = false; if (urr->info & URR_INFO_MNOP) From a7ccff39c0ce0b48901325ed3b878fe8d572c0e8 Mon Sep 17 00:00:00 2001 From: ycchen Date: Fri, 1 Nov 2024 09:54:56 +0800 Subject: [PATCH 2/2] Update pdr_fill if no FAR is found. --- src/genl/genl_pdr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/genl/genl_pdr.c b/src/genl/genl_pdr.c index 10e8036..ff854fb 100644 --- a/src/genl/genl_pdr.c +++ b/src/genl/genl_pdr.c @@ -473,8 +473,8 @@ static int pdr_fill(struct pdr *pdr, struct gtp5g_dev *gtp, struct genl_info *in pdr->af = AF_INET; far = find_far_by_id(gtp, pdr->seid, *pdr->far_id); - if (far) { - rcu_assign_pointer(pdr->far, far); + if (!far) { + return -EINVAL; } err = far_set_pdr(pdr, gtp);