From owner-svn-src-stable-9@FreeBSD.ORG Wed Oct 9 18:45:43 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 28066155; Wed, 9 Oct 2013 18:45:43 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 14C712CA8; Wed, 9 Oct 2013 18:45:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r99Ijg87054302; Wed, 9 Oct 2013 18:45:42 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r99IjgAM054300; Wed, 9 Oct 2013 18:45:42 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201310091845.r99IjgAM054300@svn.freebsd.org> From: Alexander Motin Date: Wed, 9 Oct 2013 18:45:42 +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: r256214 - stable/9/sys/cam/ctl 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-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Oct 2013 18:45:43 -0000 Author: mav Date: Wed Oct 9 18:45:42 2013 New Revision: 256214 URL: http://svnweb.freebsd.org/changeset/base/256214 Log: MFC r249256 (by ken): 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. Modified: stable/9/sys/cam/ctl/ctl.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/ctl/ctl.c ============================================================================== --- stable/9/sys/cam/ctl/ctl.c Wed Oct 9 18:45:01 2013 (r256213) +++ stable/9/sys/cam/ctl/ctl.c Wed Oct 9 18:45:42 2013 (r256214) @@ -4217,7 +4217,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); @@ -4239,11 +4239,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); /* @@ -4295,7 +4299,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;