From e87e3df67487676e9545c983c03c13fd644c5cf5 Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Tue, 14 Jun 2016 15:19:38 +0800 Subject: [PATCH] event: fix null pointer issue in spdk_subsystem_fini The variable cur could be null, so if we use do while will cause a segment fault Change-Id: I19ec26e88948a0c3fd957e03e717b68750f40c62 Signed-off-by: Ziye Yang --- lib/event/subsystem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/event/subsystem.c b/lib/event/subsystem.c index eb319914a..7edd92ba1 100644 --- a/lib/event/subsystem.c +++ b/lib/event/subsystem.c @@ -149,14 +149,16 @@ spdk_subsystem_fini(void) struct spdk_subsystem *cur; cur = TAILQ_LAST(&g_subsystems, spdk_subsystem_list); - do { + + while (cur) { if (cur->fini) { rc = cur->fini(); if (rc) return rc; } cur = TAILQ_PREV(cur, spdk_subsystem_list, tailq); - } while (cur); + } + return rc; }