net: l2: ppp: validate pointer before dereferencing it
See https://habr.com/en/company/pvs-studio/blog/495284/ fragment 9. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
cbce6dde4c
commit
4fb4d280d3
1 changed files with 3 additions and 3 deletions
|
@ -359,14 +359,14 @@ int ppp_send_pkt(struct ppp_fsm *fsm, struct net_if *iface,
|
||||||
if (!iface) {
|
if (!iface) {
|
||||||
struct ppp_context *ctx;
|
struct ppp_context *ctx;
|
||||||
|
|
||||||
if (fsm->protocol == PPP_LCP) {
|
if (fsm && fsm->protocol == PPP_LCP) {
|
||||||
ctx = CONTAINER_OF(fsm, struct ppp_context, lcp.fsm);
|
ctx = CONTAINER_OF(fsm, struct ppp_context, lcp.fsm);
|
||||||
#if defined(CONFIG_NET_IPV4)
|
#if defined(CONFIG_NET_IPV4)
|
||||||
} else if (fsm->protocol == PPP_IPCP) {
|
} else if (fsm && fsm->protocol == PPP_IPCP) {
|
||||||
ctx = CONTAINER_OF(fsm, struct ppp_context, ipcp.fsm);
|
ctx = CONTAINER_OF(fsm, struct ppp_context, ipcp.fsm);
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_NET_IPV6)
|
#if defined(CONFIG_NET_IPV6)
|
||||||
} else if (fsm->protocol == PPP_IPV6CP) {
|
} else if (fsm && fsm->protocol == PPP_IPV6CP) {
|
||||||
ctx = CONTAINER_OF(fsm, struct ppp_context,
|
ctx = CONTAINER_OF(fsm, struct ppp_context,
|
||||||
ipv6cp.fsm);
|
ipv6cp.fsm);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue