From 7b7ac845c551015f63282162501525962daf4c71 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 23 Aug 2022 23:11:28 +0200 Subject: [PATCH] host: deal with host/peer null pointers in debug messages Signed-off-by: Felix Fietkau --- host.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/host.h b/host.h index bf61e75..985ac45 100644 --- a/host.h +++ b/host.h @@ -49,13 +49,20 @@ struct network_group { static inline const char *network_host_name(struct network_host *host) { + if (!host) + return "(none)"; + return host->node.key; } static inline const char *network_peer_name(struct network_peer *peer) { - struct network_host *host = container_of(peer, struct network_host, peer); + struct network_host *host; + + if (!peer) + return "(none)"; + host = container_of(peer, struct network_host, peer); return network_host_name(host); } -- 2.30.2