svn commit: r256214 - stable/9/sys/cam/ctl
Alexander Motin
mav at FreeBSD.org
Wed Oct 9 18:45:43 UTC 2013
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;
More information about the svn-src-stable-9
mailing list