diff options
author | Kenneth D. Merry <ken@FreeBSD.org> | 2013-04-08 15:36:26 +0000 |
---|---|---|
committer | Kenneth D. Merry <ken@FreeBSD.org> | 2013-04-08 15:36:26 +0000 |
commit | 1fe2e04bb605267a8690ca086ede6b147e7263ce (patch) | |
tree | cae2317578d50bdbed33ece55931623801e5371d /sys/cam/ctl/ctl.c | |
parent | 2a2a1074f1d29780a07516846f7595195eae8f4b (diff) | |
download | src-1fe2e04bb605267a8690ca086ede6b147e7263ce.tar.gz src-1fe2e04bb605267a8690ca086ede6b147e7263ce.zip |
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 <shonnur@chelsio.com>
Sponsored by: Spectra Logic
MFC after: 3 days
Notes
Notes:
svn path=/head/; revision=249256
Diffstat (limited to 'sys/cam/ctl/ctl.c')
-rw-r--r-- | sys/cam/ctl/ctl.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 08a8081b8e76..cced79d3026a 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -4223,7 +4223,7 @@ ctl_alloc_lun(struct ctl_softc *ctl_softc, struct ctl_lun *ctl_lun, { 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_softc, struct ctl_lun *ctl_lun, } 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_softc, struct ctl_lun *ctl_lun, * 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; |