From fa660450ebb8fe4c0c463ded43950c1616aac00e Mon Sep 17 00:00:00 2001 From: mjg Date: Mon, 11 Jun 2012 17:42:39 +0000 Subject: Fix unloading of libiconv module. Previously it would either loop infinitely or exit with error leaking a lock. Reported by: Will DeVries Approved by: trasz (mentor) MFC after: 1 week --- sys/libkern/iconv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sys/libkern') diff --git a/sys/libkern/iconv.c b/sys/libkern/iconv.c index ed928f0..dcdb119 100644 --- a/sys/libkern/iconv.c +++ b/sys/libkern/iconv.c @@ -84,9 +84,11 @@ iconv_mod_unload(void) struct iconv_cspair *csp; sx_xlock(&iconv_lock); - while ((csp = TAILQ_FIRST(&iconv_cslist)) != NULL) { - if (csp->cp_refcount) + TAILQ_FOREACH(csp, &iconv_cslist, cp_link) { + if (csp->cp_refcount) { + sx_xunlock(&iconv_lock); return EBUSY; + } } while ((csp = TAILQ_FIRST(&iconv_cslist)) != NULL) -- cgit v1.1