From owner-svn-src-all@FreeBSD.ORG Wed Apr 10 17:51:15 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 98AC8FB0; Wed, 10 Apr 2013 17:51:15 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8B62DE3F; Wed, 10 Apr 2013 17:51:15 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r3AHpFH7017042; Wed, 10 Apr 2013 17:51:15 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r3AHpFVg017041; Wed, 10 Apr 2013 17:51:15 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201304101751.r3AHpFVg017041@svn.freebsd.org> From: Alexander Motin Date: Wed, 10 Apr 2013 17:51:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r249338 - stable/8/sys/cam X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Apr 2013 17:51:15 -0000 Author: mav Date: Wed Apr 10 17:51:15 2013 New Revision: 249338 URL: http://svnweb.freebsd.org/changeset/base/249338 Log: MFC r248800: On SIM destruction free associated CCBs, preallocated inside xpt_get_ccb(). Before this change they were just leaked. Fortunately USB sticks now use only one CCB, and so leak was only 2KB per detach, while other bigger SIMs with much more allocated CCBs are rarely detached. Modified: stable/8/sys/cam/cam_sim.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/cam/ (props changed) Modified: stable/8/sys/cam/cam_sim.c ============================================================================== --- stable/8/sys/cam/cam_sim.c Wed Apr 10 17:49:25 2013 (r249337) +++ stable/8/sys/cam/cam_sim.c Wed Apr 10 17:51:15 2013 (r249338) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #define CAM_PATH_ANY (u_int32_t)-1 @@ -105,6 +106,7 @@ cam_sim_alloc(sim_action_func sim_action void cam_sim_free(struct cam_sim *sim, int free_devq) { + union ccb *ccb; int error; sim->refcount--; @@ -115,6 +117,10 @@ cam_sim_free(struct cam_sim *sim, int fr KASSERT(sim->refcount == 0, ("sim->refcount == 0")); + while ((ccb = (union ccb *)SLIST_FIRST(&sim->ccb_freeq)) != NULL) { + SLIST_REMOVE_HEAD(&sim->ccb_freeq, xpt_links.sle); + xpt_free_ccb(ccb); + } if (free_devq) cam_simq_free(sim->devq); free(sim, M_CAMSIM);