svn commit: r249337 - stable/9/sys/cam

Alexander Motin mav at FreeBSD.org
Wed Apr 10 17:49:26 UTC 2013


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);


More information about the svn-src-stable-9 mailing list