From owner-svn-src-stable@FreeBSD.ORG Tue Oct 23 15:25:19 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B51C0663; Tue, 23 Oct 2012 15:25:19 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9D3908FC17; Tue, 23 Oct 2012 15:25:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q9NFPJKc096567; Tue, 23 Oct 2012 15:25:19 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9NFPJna096564; Tue, 23 Oct 2012 15:25:19 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201210231525.q9NFPJna096564@svn.freebsd.org> From: Alexander Motin Date: Tue, 23 Oct 2012 15:25:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r241941 - stable/9/sys/cam X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Oct 2012 15:25:19 -0000 Author: mav Date: Tue Oct 23 15:25:19 2012 New Revision: 241941 URL: http://svn.freebsd.org/changeset/base/241941 Log: MFC r241456: Use separate malloc buckets for CAM devices, CCBs and paths. This will make it easier to track down the source of any use after free problems. Modified: stable/9/sys/cam/cam_xpt.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/cam_xpt.c ============================================================================== --- stable/9/sys/cam/cam_xpt.c Tue Oct 23 15:22:11 2012 (r241940) +++ stable/9/sys/cam/cam_xpt.c Tue Oct 23 15:25:19 2012 (r241941) @@ -78,6 +78,9 @@ __FBSDID("$FreeBSD$"); /* Datastructures internal to the xpt layer */ MALLOC_DEFINE(M_CAMXPT, "CAM XPT", "CAM XPT buffers"); +MALLOC_DEFINE(M_CAMDEV, "CAM DEV", "CAM devices"); +MALLOC_DEFINE(M_CAMCCB, "CAM CCB", "CAM CCBs"); +MALLOC_DEFINE(M_CAMPATH, "CAM path", "CAM paths"); /* Object for defering XPT actions to a taskqueue */ struct xpt_task { @@ -3397,7 +3400,7 @@ xpt_create_path(struct cam_path **new_pa struct cam_path *path; cam_status status; - path = (struct cam_path *)malloc(sizeof(*path), M_CAMXPT, M_NOWAIT); + path = (struct cam_path *)malloc(sizeof(*path), M_CAMPATH, M_NOWAIT); if (path == NULL) { status = CAM_RESRC_UNAVAIL; @@ -3405,7 +3408,7 @@ xpt_create_path(struct cam_path **new_pa } status = xpt_compile_path(path, perph, path_id, target_id, lun_id); if (status != CAM_REQ_CMP) { - free(path, M_CAMXPT); + free(path, M_CAMPATH); path = NULL; } *new_path_ptr = path; @@ -3422,7 +3425,7 @@ xpt_create_path_unlocked(struct cam_path cam_status status; int need_unlock = 0; - path = (struct cam_path *)malloc(sizeof(*path), M_CAMXPT, M_WAITOK); + path = (struct cam_path *)malloc(sizeof(*path), M_CAMPATH, M_WAITOK); if (path_id != CAM_BUS_WILDCARD) { bus = xpt_find_bus(path_id); @@ -3437,7 +3440,7 @@ xpt_create_path_unlocked(struct cam_path xpt_release_bus(bus); } if (status != CAM_REQ_CMP) { - free(path, M_CAMXPT); + free(path, M_CAMPATH); path = NULL; } *new_path_ptr = path; @@ -3540,7 +3543,7 @@ xpt_free_path(struct cam_path *path) CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_free_path\n")); xpt_release_path(path); - free(path, M_CAMXPT); + free(path, M_CAMPATH); } void @@ -4376,7 +4379,7 @@ xpt_alloc_ccb() { union ccb *new_ccb; - new_ccb = malloc(sizeof(*new_ccb), M_CAMXPT, M_ZERO|M_WAITOK); + new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_WAITOK); return (new_ccb); } @@ -4385,14 +4388,14 @@ xpt_alloc_ccb_nowait() { union ccb *new_ccb; - new_ccb = malloc(sizeof(*new_ccb), M_CAMXPT, M_ZERO|M_NOWAIT); + new_ccb = malloc(sizeof(*new_ccb), M_CAMCCB, M_ZERO|M_NOWAIT); return (new_ccb); } void xpt_free_ccb(union ccb *free_ccb) { - free(free_ccb, M_CAMXPT); + free(free_ccb, M_CAMCCB); } @@ -4544,7 +4547,7 @@ xpt_alloc_device(struct cam_eb *bus, str device = NULL; } else { device = (struct cam_ed *)malloc(sizeof(*device), - M_CAMXPT, M_NOWAIT|M_ZERO); + M_CAMDEV, M_NOWAIT|M_ZERO); } if (device != NULL) { @@ -4557,13 +4560,13 @@ xpt_alloc_device(struct cam_eb *bus, str device->sim = bus->sim; /* Initialize our queues */ if (camq_init(&device->drvq, 0) != 0) { - free(device, M_CAMXPT); + free(device, M_CAMDEV); return (NULL); } if (cam_ccbq_init(&device->ccbq, bus->sim->max_dev_openings) != 0) { camq_fini(&device->drvq); - free(device, M_CAMXPT); + free(device, M_CAMDEV); return (NULL); } SLIST_INIT(&device->asyncs); @@ -4616,7 +4619,7 @@ xpt_release_device(struct cam_ed *device camq_fini(&device->drvq); cam_ccbq_fini(&device->ccbq); xpt_release_target(device->target); - free(device, M_CAMXPT); + free(device, M_CAMDEV); } else device->refcount--; }