pbrd: Prevent possible NULL use

the pnhi data structure can receive either a interface or a
nhr data structure.  Ensure that we don't crash.

CID -> 1500586
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2021-01-17 07:48:20 -05:00
parent 5c8ecf6e46
commit 920bb6f76a

View File

@ -770,6 +770,7 @@ pbr_nht_individual_nexthop_gw_update(struct pbr_nexthop_cache *pnhc,
goto done; goto done;
} }
if (pnhi->nhr) {
switch (pnhi->nhr->prefix.family) { switch (pnhi->nhr->prefix.family) {
case AF_INET: case AF_INET:
if (pnhc->nexthop.gate.ipv4.s_addr if (pnhc->nexthop.gate.ipv4.s_addr
@ -783,6 +784,7 @@ pbr_nht_individual_nexthop_gw_update(struct pbr_nexthop_cache *pnhc,
goto done; /* Unrelated change */ goto done; /* Unrelated change */
break; break;
} }
}
pnhi->nhr_matched = true; pnhi->nhr_matched = true;
if (!pnhi->nhr->nexthop_num) { if (!pnhi->nhr->nexthop_num) {