From 1fe6ed38cd0136c514aabae01389653beab27fb9 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Wed, 26 Jul 2006 09:37:26 +0000 Subject: [ospfd] Allow ospf_lsa_unlock to NULL out callers' LSA pointers upon free 2006-07-26 Paul Jakma * ospf_lsa.{c,h}: (ospf_lsa_unlock) Change to take a double pointer to the LSA to be 'unlocked', so that, if the LSA is freed, the callers pointer to the LSA can be NULLed out, allowing any further use of that pointer to provoke a crash sooner rather than later. * ospf_*.c: (general) Adjust callers of ospf_lsa_unlock to match previous. Try annotate 'locking' somewhat to show which 'locks' are protecting what LSA reference, if not obvious. * ospf_opaque.c: (ospf_opaque_lsa_install) Trivial: remove useless goto, replace with return. * ospf_packet.c: (ospf_make_ls_ack) Trivial: merge two list loops, the dual-loop predated the delete-safe list-loop macro. --- ospfd/ospf_opaque.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'ospfd/ospf_opaque.c') diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c index f2496cfd7..0b6ac4cb7 100644 --- a/ospfd/ospf_opaque.c +++ b/ospfd/ospf_opaque.c @@ -708,7 +708,7 @@ free_opaque_info_per_id (void *val) OSPF_TIMER_OFF (oipi->t_opaque_lsa_self); if (oipi->lsa != NULL) - ospf_lsa_unlock (oipi->lsa); + ospf_lsa_unlock (&oipi->lsa); XFREE (MTYPE_OPAQUE_INFO_PER_ID, oipi); return; } @@ -1554,7 +1554,7 @@ ospf_opaque_lsa_install (struct ospf_lsa *lsa, int rt_recalc) if ((oipt = lookup_opaque_info_by_type (lsa)) != NULL && (oipi = lookup_opaque_info_by_id (oipt, lsa)) != NULL) { - ospf_lsa_unlock (oipi->lsa); + ospf_lsa_unlock (&oipi->lsa); oipi->lsa = ospf_lsa_lock (lsa); } /* Register the new lsa entry and get its control info. */ @@ -2234,7 +2234,7 @@ ospf_opaque_self_originated_lsa_received (struct ospf_neighbor *nbr, u_char before; if ((top = oi_to_top (nbr->oi)) == NULL) - goto out; + return; before = IS_OPAQUE_LSA_ORIGINATION_BLOCKED (top->opaque); @@ -2259,7 +2259,7 @@ ospf_opaque_self_originated_lsa_received (struct ospf_neighbor *nbr, break; default: zlog_warn ("ospf_opaque_self_originated_lsa_received: Unexpected LSA-type(%u)", lsa->data->type); - goto out; + return; } ospf_lsa_discard (lsa); /* List "lsas" will be deleted by caller. */ @@ -2269,9 +2269,6 @@ ospf_opaque_self_originated_lsa_received (struct ospf_neighbor *nbr, if (IS_DEBUG_OSPF_EVENT) zlog_debug ("Block Opaque-LSA origination: OFF -> ON"); } - -out: - return; } void -- cgit v1.2.3