From 62cf60165fd67a9ef940bdeefcddf9f91974f744 Mon Sep 17 00:00:00 2001 From: Reyk Floeter Date: Wed, 21 Dec 2005 18:41:56 +0000 Subject: fix possible NULL pointer, thanks to Marco Molteni --- sys/net/if_trunk.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'sys') diff --git a/sys/net/if_trunk.c b/sys/net/if_trunk.c index c859d559f9e..3345d5b87ca 100644 --- a/sys/net/if_trunk.c +++ b/sys/net/if_trunk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_trunk.c,v 1.16 2005/12/18 17:59:59 reyk Exp $ */ +/* $OpenBSD: if_trunk.c,v 1.17 2005/12/21 18:41:55 reyk Exp $ */ /* * Copyright (c) 2005 Reyk Floeter @@ -496,7 +496,11 @@ trunk_port_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) fallback: splx(s); - return ((*tp->tp_ioctl)(ifp, cmd, data)); + + if (tp != NULL) + return ((*tp->tp_ioctl)(ifp, cmd, data)); + + return (EINVAL); } void @@ -938,7 +942,7 @@ trunk_input(struct ifnet *ifp, struct ether_header *eh, struct mbuf *m) return (0); bad: - if (trifp) + if (trifp != NULL) trifp->if_ierrors++; return (error); } @@ -970,17 +974,16 @@ trunk_media_status(struct ifnet *ifp, struct ifmediareq *imr) } void -trunk_port_state(void *v) +trunk_port_state(void *arg) { - struct trunk_port *tp = v; - struct trunk_softc *tr; + struct trunk_port *tp = (struct trunk_port *)arg; + struct trunk_softc *tr = NULL; - if (v) + if (tp != NULL) tr = (struct trunk_softc *)tp->tp_trunk; - - if (!tr) + if (tr == NULL) return; - + trunk_link_active(tr, tp); } -- cgit v1.2.3