if (port->parent)
lldpctl_atom_inc_ref((lldpctl_atom_t*)port->parent);
- /* Internal atom. We are the parent, but our reference count is not
- * incremented. */
- port->chassis = _lldpctl_new_atom(atom->conn, atom_chassis,
- port->port->p_chassis, port, 1);
+ if (port->port) {
+ /* Internal atom. We are the parent, but our reference count is
+ * not incremented. */
+ port->chassis = _lldpctl_new_atom(atom->conn, atom_chassis,
+ port->port->p_chassis, port, 1);
+ }
return 1;
}
TAILQ_INIT(&chassis_list);
if (port->parent) lldpctl_atom_dec_ref((lldpctl_atom_t*)port->parent);
- else if (!hardware) {
+ else if (!hardware && port->port) {
/* No parent, no hardware, we assume a single neighbor: one
* port, one chassis. */
if (port->port->p_chassis) {
default: break;
}
+ if (!port)
+ return NULL;
+
/* Local and remote port */
switch (key) {
case lldpctl_k_port_protocol:
default: break;
}
}
+ if (!port)
+ return SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST);
/* Local and remote port */
switch (key) {