From 23ee1bfa82ae1b43e7ec6e9136971b66d1a07180 Mon Sep 17 00:00:00 2001 From: Kip Macy Date: Tue, 16 Dec 2008 02:47:22 +0000 Subject: [PATCH] explicitly check return of lla_lookup against NULL --- sys/netinet6/nd6.c | 10 +++++----- sys/netinet6/nd6_nbr.c | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 898af794868f..fae9816ad30b 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1433,14 +1433,14 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr, flags |= lladdr ? ND6_EXCLUSIVE : 0; IF_AFDATA_LOCK(ifp); ln = nd6_lookup(from, flags, ifp); - if (ln) - IF_AFDATA_UNLOCK(ifp); + if (ln == NULL) { flags |= LLE_EXCLUSIVE; ln = nd6_lookup(from, flags |ND6_CREATE, ifp); IF_AFDATA_UNLOCK(ifp); is_newentry = 1; } else { + IF_AFDATA_UNLOCK(ifp); /* do nothing if static ndp is set */ if (ln->la_flags & LLE_STATIC) { static_route = 1; @@ -1604,7 +1604,7 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr, break; } - if (ln) { + if (ln != NULL) { static_route = (ln->la_flags & LLE_STATIC); router = ln->ln_router; @@ -1878,7 +1878,7 @@ nd6_output_lle(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0, * ln is valid and the caller did not pass in * an llentry */ - if (ln && (lle == NULL)) { + if ((ln != NULL) && (lle == NULL)) { if (flags & LLE_EXCLUSIVE) LLE_WUNLOCK(ln); else @@ -1909,7 +1909,7 @@ nd6_output_lle(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0, * ln is valid and the caller did not pass in * an llentry */ - if (ln && (lle == NULL)) { + if ((ln != NULL) && (lle == NULL)) { if (flags & LLE_EXCLUSIVE) LLE_WUNLOCK(ln); else diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c index 2dcabdb7cdec..c1cb423407cb 100644 --- a/sys/netinet6/nd6_nbr.c +++ b/sys/netinet6/nd6_nbr.c @@ -474,7 +474,7 @@ nd6_ns_output(struct ifnet *ifp, const struct in6_addr *daddr6, struct ip6_hdr *hip6; /* hold ip6 */ struct in6_addr *hsrc = NULL; - if (ln && ln->la_hold) { + if ((ln != NULL) && ln->la_hold) { /* * assuming every packet in la_hold has the same IP * header @@ -878,7 +878,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len) } } freeit: - if (ln) { + if (ln != NULL) { if (chain) memcpy(&sin6, L3_ADDR_SIN6(ln), sizeof(sin6)); LLE_WUNLOCK(ln); @@ -890,7 +890,7 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len) return; bad: - if (ln) + if (ln != NULL) LLE_WUNLOCK(ln); V_icmp6stat.icp6s_badna++;