aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2021-10-27 10:56:38 +0200
committerDamjan Marion <dmarion@me.com>2021-10-29 16:20:52 +0000
commitba87563bee400f8ce6d99842a6e455c898cf2c1d (patch)
treee0651083706b8809ea694f9e75033cae7440efaa /src
parentb225b0a2af66b0a3a007d50877638f7489acbaf3 (diff)
policer: fix coverity warning/NULL dereference
Add a NULL check in case of hash lookup failure to make coverity happy. Type: fix Signed-off-by: Klement Sekera <ksekera@cisco.com> Change-Id: I3cfa5960458d3618f1277ba442b4ca5ca15064ea
Diffstat (limited to 'src')
-rw-r--r--src/vnet/policer/policer.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/vnet/policer/policer.c b/src/vnet/policer/policer.c
index 516a029dcee..9eb56414561 100644
--- a/src/vnet/policer/policer.c
+++ b/src/vnet/policer/policer.c
@@ -737,8 +737,16 @@ show_policer_command_fn (vlib_main_t * vm,
templ = pool_elt_at_index (pm->policer_templates, pool_index);
vlib_cli_output (vm, "Name \"%s\" %U ", name, format_policer_config,
config);
- vlib_cli_output (vm, "Template %U", format_policer_instance, templ,
- pi[0]);
+ if (pi)
+ {
+ vlib_cli_output (vm, "Template %U", format_policer_instance, templ,
+ pi[0]);
+ }
+ else
+ {
+ vlib_cli_output (
+ vm, "Cannot print template - policer index hash lookup failed");
+ }
vlib_cli_output (vm, "-----------");
}
}));