Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Apr 2013 17:51:15 +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-8@freebsd.org
Subject:   svn commit: r249338 - stable/8/sys/cam
Message-ID:  <201304101751.r3AHpFVg017041@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <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?201304101751.r3AHpFVg017041>