diff options
| author | Carmine Scarpitta <cscarpit@cisco.com> | 2024-08-18 13:02:06 +0200 |
|---|---|---|
| committer | Carmine Scarpitta <cscarpit@cisco.com> | 2024-08-18 13:03:04 +0200 |
| commit | 354f9e9009326d695edf4b39d6fcc5feb9f3e8cf (patch) | |
| tree | 183f8e9ad6d45256e5bb1214746b735cec580127 /zebra/zebra_srv6_vty.c | |
| parent | 075899dee063a690219c0d3e7c2d4d05136cac08 (diff) | |
zebra: Fix compilation warning
Make sure the variable `srv6` is not NULL before dereferencing it.
Fixes the following compilation warnings:
```
error 15-Aug-2024 14:20:01 zebra/zebra_srv6_vty.c:974:8: warning: Access to field 'locators' results in a dereference of a null pointer (loaded from variable 'srv6') [core.NullDereference]
error 15-Aug-2024 14:20:01 for (ALL_LIST_ELEMENTS_RO(srv6->locators, node, locator)) {
error 15-Aug-2024 14:20:01 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error 15-Aug-2024 14:20:01 ./lib/linklist.h:345:11: note: expanded from macro 'ALL_LIST_ELEMENTS_RO'
error 15-Aug-2024 14:20:01 (node) = listhead(list), ((data) = NULL); \
error 15-Aug-2024 14:20:01 ^~~~~~~~~~~~~~
error 15-Aug-2024 14:20:01 ./lib/linklist.h:63:22: note: expanded from macro 'listhead'
error 15-Aug-2024 14:20:01 #define listhead(X) ((X) ? ((X)->head) : NULL)
error 15-Aug-2024 14:20:01 ^
```
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
Diffstat (limited to 'zebra/zebra_srv6_vty.c')
| -rw-r--r-- | zebra/zebra_srv6_vty.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/zebra/zebra_srv6_vty.c b/zebra/zebra_srv6_vty.c index c664a9c69f..5a80524149 100644 --- a/zebra/zebra_srv6_vty.c +++ b/zebra/zebra_srv6_vty.c @@ -969,7 +969,7 @@ static int zebra_sr_config(struct vty *vty) &srv6->encap_src_addr); } } - if (zebra_srv6_is_enable()) { + if (srv6 && zebra_srv6_is_enable()) { vty_out(vty, " locators\n"); for (ALL_LIST_ELEMENTS_RO(srv6->locators, node, locator)) { inet_ntop(AF_INET6, &locator->prefix.prefix, |
