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.
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);
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);