From 3e9fa3be62d2f39f4ad997427a0c06a50a8ccea2 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 11 Oct 2014 13:43:27 +0300 Subject: [PATCH] WPS UPnP: Make dl_list_first() use easier for static analyzer The preceding dl_list_len() check guarantees that dl_list_first() returns an entry and not NULL. However, that seems to be a bit too difficult path to follow for static analyzers, so add an explicit check for the dl_list_first() return value to be non-NULL to avoid warnings. Signed-off-by: Jouni Malinen --- src/wps/wps_upnp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/wps/wps_upnp.c b/src/wps/wps_upnp.c index ae94a9f62..993db8389 100644 --- a/src/wps/wps_upnp.c +++ b/src/wps/wps_upnp.c @@ -700,10 +700,12 @@ struct subscription * subscription_start(struct upnp_wps_device_sm *sm, if (dl_list_len(&sm->subscriptions) >= MAX_SUBSCRIPTIONS) { s = dl_list_first(&sm->subscriptions, struct subscription, list); - wpa_printf(MSG_INFO, "WPS UPnP: Too many subscriptions, " - "trashing oldest"); - dl_list_del(&s->list); - subscription_destroy(s); + if (s) { + wpa_printf(MSG_INFO, + "WPS UPnP: Too many subscriptions, trashing oldest"); + dl_list_del(&s->list); + subscription_destroy(s); + } } s = os_zalloc(sizeof(*s));