Skip to content

Commit

Permalink
gk: check_prefix_exists_locked() sets returned pointer to NULL
Browse files Browse the repository at this point in the history
Making check_prefix_exists_locked() set to NULL
the returned pointer to the found FIB entry increases
the chance that a bug will lead to a segmentation fault instead of
silently corrupting the memory.
  • Loading branch information
AltraMayor committed Aug 25, 2021
1 parent f970f7b commit 04f3a42
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions gk/fib.c
Expand Up @@ -978,12 +978,16 @@ check_prefix_exists_locked(struct ip_prefix *prefix, struct gk_config *gk_conf,
} else {
GK_LOG(WARNING, "%s(): Unknown IP type %hu with prefix %s\n",
__func__, prefix->addr.proto, prefix->str);
if (p_fib != NULL)
*p_fib = NULL;
return -EINVAL;
}

if (ret == 1)
return fib_id;
if (ret == 0)
if (p_fib != NULL)
*p_fib = NULL;
if (likely(ret == 0))
return -ENOENT;
RTE_VERIFY(ret < 0 && ret != -ENOENT);
return ret;
Expand Down Expand Up @@ -1643,7 +1647,7 @@ update_fib_entry_numerical(struct ip_prefix *prefix_info,
{
int ret, fib_id;
unsigned int i;
struct gk_fib *cur_fib = NULL;
struct gk_fib *cur_fib;

if (prefix_info->len < 0)
return -1;
Expand Down

0 comments on commit 04f3a42

Please sign in to comment.