From owner-svn-src-head@FreeBSD.ORG Wed Apr 9 19:16:41 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 357B915C; Wed, 9 Apr 2014 19:16:41 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 22D0A134C; Wed, 9 Apr 2014 19:16:41 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s39JGf0r092733; Wed, 9 Apr 2014 19:16:41 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s39JGedV092732; Wed, 9 Apr 2014 19:16:40 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201404091916.s39JGedV092732@svn.freebsd.org> From: Alexander Motin Date: Wed, 9 Apr 2014 19:16:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r264307 - head/sys/cam/ctl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Apr 2014 19:16:41 -0000 Author: mav Date: Wed Apr 9 19:16:40 2014 New Revision: 264307 URL: http://svnweb.freebsd.org/changeset/base/264307 Log: Fix three refcounter leaks and lock recursion they covered. MFC after: 1 week Modified: head/sys/cam/ctl/ctl_frontend_iscsi.c Modified: head/sys/cam/ctl/ctl_frontend_iscsi.c ============================================================================== --- head/sys/cam/ctl/ctl_frontend_iscsi.c Wed Apr 9 19:01:48 2014 (r264306) +++ head/sys/cam/ctl/ctl_frontend_iscsi.c Wed Apr 9 19:16:40 2014 (r264307) @@ -1455,6 +1455,7 @@ cfiscsi_ioctl_handoff(struct ctl_iscsi * mtx_unlock(&cfiscsi_softc.lock); snprintf(ci->error_str, sizeof(ci->error_str), "connection not found"); ci->status = CTL_ISCSI_ERROR; + cfiscsi_target_release(ct); return; } mtx_unlock(&cfiscsi_softc.lock); @@ -2093,15 +2094,9 @@ cfiscsi_target_hold(struct cfiscsi_targe static void cfiscsi_target_release(struct cfiscsi_target *ct) { - int old; struct cfiscsi_softc *softc; softc = ct->ct_softc; - - old = ct->ct_refcount; - if (old > 1 && atomic_cmpset_int(&ct->ct_refcount, old, old - 1)) - return; - mtx_lock(&softc->lock); if (refcount_release(&ct->ct_refcount)) { TAILQ_REMOVE(&softc->targets, ct, ct_next); @@ -2278,6 +2273,7 @@ cfiscsi_lun_enable(void *arg, struct ctl tmp = strtoul(lun, NULL, 10); cfiscsi_target_set_lun(ct, tmp, lun_id); + cfiscsi_target_release(ct); return (0); } @@ -2297,8 +2293,9 @@ cfiscsi_lun_disable(void *arg, struct ct continue; if (ct->ct_luns[i] != lun_id) continue; + mtx_unlock(&softc->lock); cfiscsi_target_unset_lun(ct, i); - break; + return (0); } } mtx_unlock(&softc->lock);