Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Apr 2013 17:49:26 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r249337 - stable/9/sys/cam
Message-ID:  <201304101749.r3AHnQjs015131@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Apr 10 17:49:25 2013
New Revision: 249337
URL: http://svnweb.freebsd.org/changeset/base/249337

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/9/sys/cam/cam_sim.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/cam/cam_sim.c
==============================================================================
--- stable/9/sys/cam/cam_sim.c	Wed Apr 10 17:43:20 2013	(r249336)
+++ stable/9/sys/cam/cam_sim.c	Wed Apr 10 17:49:25 2013	(r249337)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include <cam/cam_ccb.h>
 #include <cam/cam_sim.h>
 #include <cam/cam_queue.h>
+#include <cam/cam_xpt.h>
 
 #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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201304101749.r3AHnQjs015131>