From owner-svn-src-all@FreeBSD.ORG Mon Apr 8 15:36:27 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 2A10C71; Mon, 8 Apr 2013 15:36:27 +0000 (UTC) (envelope-from ken@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 1CBD9616; Mon, 8 Apr 2013 15:36:27 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r38FaQpT021182; Mon, 8 Apr 2013 15:36:26 GMT (envelope-from ken@svn.freebsd.org) Received: (from ken@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r38FaQfW021181; Mon, 8 Apr 2013 15:36:26 GMT (envelope-from ken@svn.freebsd.org) Message-Id: <201304081536.r38FaQfW021181@svn.freebsd.org> From: "Kenneth D. Merry" Date: Mon, 8 Apr 2013 15:36:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r249256 - head/sys/cam/ctl X-SVN-Group: head 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: Mon, 08 Apr 2013 15:36:27 -0000 Author: ken Date: Mon Apr 8 15:36:26 2013 New Revision: 249256 URL: http://svnweb.freebsd.org/changeset/base/249256 Log: Fix a memory leak that showed up when we delete LUNs. The memory used for the LUN was never freed. ctl.c: Adjust ctl_alloc_lun() to make sure we don't clear the CTL_LUN_MALLOCED flag. Reported by: Sreenivasa Honnur Sponsored by: Spectra Logic MFC after: 3 days Modified: head/sys/cam/ctl/ctl.c Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Mon Apr 8 15:13:15 2013 (r249255) +++ head/sys/cam/ctl/ctl.c Mon Apr 8 15:36:26 2013 (r249256) @@ -4223,7 +4223,7 @@ ctl_alloc_lun(struct ctl_softc *ctl_soft { struct ctl_lun *nlun, *lun; struct ctl_frontend *fe; - int lun_number, i; + int lun_number, i, lun_malloced; if (be_lun == NULL) return (EINVAL); @@ -4245,11 +4245,15 @@ ctl_alloc_lun(struct ctl_softc *ctl_soft } if (ctl_lun == NULL) { lun = malloc(sizeof(*lun), M_CTL, M_WAITOK); - lun->flags = CTL_LUN_MALLOCED; - } else + lun_malloced = 1; + } else { + lun_malloced = 0; lun = ctl_lun; + } memset(lun, 0, sizeof(*lun)); + if (lun_malloced) + lun->flags = CTL_LUN_MALLOCED; mtx_lock(&ctl_softc->ctl_lock); /* @@ -4301,7 +4305,7 @@ ctl_alloc_lun(struct ctl_softc *ctl_soft * The processor LUN is always enabled. Disk LUNs come on line * disabled, and must be enabled by the backend. */ - lun->flags = CTL_LUN_DISABLED; + lun->flags |= CTL_LUN_DISABLED; lun->backend = be_lun->be; be_lun->ctl_lun = lun; be_lun->lun_id = lun_number;