From: Vincent Bernat Date: Sun, 31 Aug 2014 19:56:49 +0000 (+0200) Subject: lldpd: handle early cleanup in case interface cannot be created X-Git-Tag: 0.7.11~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dbfa89c6e597011144032f1bcde300cfe2c64e47;p=thirdparty%2Flldpd.git lldpd: handle early cleanup in case interface cannot be created When an interface is about to be created but an external condition makes it impossible, the cleanup may crash because the interface was incomplete. Check things exist before cleanup. --- diff --git a/src/daemon/event.c b/src/daemon/event.c index 14a3855a..2379d2b4 100644 --- a/src/daemon/event.c +++ b/src/daemon/event.c @@ -570,7 +570,10 @@ void levent_hardware_release(struct lldpd_hardware *hardware) { struct lldpd_events *ev, *ev_next; - event_free(hardware->h_timer); hardware->h_timer = NULL; + if (hardware->h_timer) { + event_free(hardware->h_timer); + hardware->h_timer = NULL; + } if (!hardware->h_recv) return; log_debug("event", "release events for %s", hardware->h_ifname); diff --git a/src/daemon/lldpd.c b/src/daemon/lldpd.c index 4848f6f3..d4d83189 100644 --- a/src/daemon/lldpd.c +++ b/src/daemon/lldpd.c @@ -208,7 +208,7 @@ lldpd_hardware_cleanup(struct lldpd *cfg, struct lldpd_hardware *hardware) log_debug("alloc", "cleanup hardware port %s", hardware->h_ifname); lldpd_port_cleanup(&hardware->h_lport, 1); - if (hardware->h_ops->cleanup) + if (hardware->h_ops && hardware->h_ops->cleanup) hardware->h_ops->cleanup(cfg, hardware); levent_hardware_release(hardware); free(hardware);