Bug 138378 - [altq] [patch] Memory leak in hfsc_class_modify() in file sys/contrib/altq/altq/altq_hfsc.c
Summary: [altq] [patch] Memory leak in hfsc_class_modify() in file sys/contrib/altq/al...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 8.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: Christian Brueffer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-31 11:00 UTC by Patroklos Argyroudis
Modified: 2009-11-17 13:40 UTC (History)
0 users

See Also:


Attachments
file.diff (691 bytes, patch)
2009-08-31 11:00 UTC, Patroklos Argyroudis
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Patroklos Argyroudis 2009-08-31 11:00:16 UTC
There is a memory leak of pointers rsc_tmp and fsc_tmp if the allocations in lines 1810 and 1817 fail.

Fix: Patch attached.

Patch attached with submission follows:
How-To-Repeat: N/A
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2009-08-31 11:32:03 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-net

Over to maintainer(s).
Comment 2 dfilter service freebsd_committer freebsd_triage 2009-11-05 16:30:25 UTC
Author: brueffer
Date: Thu Nov  5 16:30:16 2009
New Revision: 198952
URL: http://svn.freebsd.org/changeset/base/198952

Log:
  Fix two memory leaks in error cases.
  
  PR:		138378
  Submitted by:	Patroklos Argyroudis <argp@census-labs.com>
  Approved by:	mlaier
  MFC after:	1 week

Modified:
  head/sys/contrib/altq/altq/altq_hfsc.c

Modified: head/sys/contrib/altq/altq/altq_hfsc.c
==============================================================================
--- head/sys/contrib/altq/altq/altq_hfsc.c	Thu Nov  5 16:16:56 2009	(r198951)
+++ head/sys/contrib/altq/altq/altq_hfsc.c	Thu Nov  5 16:30:16 2009	(r198952)
@@ -1809,15 +1809,20 @@ hfsc_class_modify(cl, rsc, fsc, usc)
 	    cl->cl_fsc == NULL) {
 		fsc_tmp = malloc(sizeof(struct internal_sc),
 		    M_DEVBUF, M_WAITOK);
-		if (fsc_tmp == NULL)
+		if (fsc_tmp == NULL) {
+			free(rsc_tmp);
 			return (ENOMEM);
+		}
 	}
 	if (usc != NULL && (usc->m1 != 0 || usc->m2 != 0) &&
 	    cl->cl_usc == NULL) {
 		usc_tmp = malloc(sizeof(struct internal_sc),
 		    M_DEVBUF, M_WAITOK);
-		if (usc_tmp == NULL)
+		if (usc_tmp == NULL) {
+			free(rsc_tmp);
+			free(fsc_tmp);
 			return (ENOMEM);
+		}
 	}
 
 	cur_time = read_machclk();
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 3 Christian Brueffer freebsd_committer freebsd_triage 2009-11-05 16:30:26 UTC
State Changed
From-To: open->patched

Committed, thanks! 


Comment 4 Christian Brueffer freebsd_committer freebsd_triage 2009-11-05 16:30:26 UTC
Responsible Changed
From-To: freebsd-net->brueffer

MFC reminder.
Comment 5 Christian Brueffer freebsd_committer freebsd_triage 2009-11-17 13:40:23 UTC
State Changed
From-To: patched->closed

MFCs done.