Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Aug 2009 09:58:25 GMT
From:      Patroklos Argyroudis <argp@census-labs.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/138378: Memory leak in hfsc_class_modify() in file sys/contrib/altq/altq/altq_hfsc.c
Message-ID:  <200908310958.n7V9wPfc051604@www.freebsd.org>
Resent-Message-ID: <200908311000.n7VA0GTl098492@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         138378
>Category:       kern
>Synopsis:       Memory leak in hfsc_class_modify() in file sys/contrib/altq/altq/altq_hfsc.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 31 10:00:16 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Patroklos Argyroudis
>Release:        8.0-CURRENT
>Organization:
census, inc
>Environment:
N/A
>Description:
There is a memory leak of pointers rsc_tmp and fsc_tmp if the allocations in lines 1810 and 1817 fail.
>How-To-Repeat:
N/A
>Fix:
Patch attached.

Patch attached with submission follows:

--- ./sys/contrib/altq/altq/altq_hfsc.c.orig	2009-08-27 17:24:01.000000000 +0300
+++ ./sys/contrib/altq/altq/altq_hfsc.c	2009-08-27 17:26:39.000000000 +0300
@@ -1809,15 +1809,20 @@
 	    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();


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908310958.n7V9wPfc051604>