From nobody@FreeBSD.org  Mon Aug 31 09:50:08 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B2213106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 31 Aug 2009 09:50:08 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id A11678FC0C
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 31 Aug 2009 09:50:08 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n7V9o88C040165
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 31 Aug 2009 09:50:08 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n7V9o8RO040164;
	Mon, 31 Aug 2009 09:50:08 GMT
	(envelope-from nobody)
Message-Id: <200908310950.n7V9o8RO040164@www.freebsd.org>
Date: Mon, 31 Aug 2009 09:50:08 GMT
From: Patroklos Argyroudis <argp@census-labs.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Memory leak in scsi_low_attach_xs() in file sys/cam/scsi/scsi_low.c
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         138376
>Category:       kern
>Synopsis:       [cam] [patch] Memory leak in scsi_low_attach_xs() in file sys/cam/scsi/scsi_low.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    brueffer
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 31 10:00:15 UTC 2009
>Closed-Date:    Sat Oct 31 12:24:37 CET 2009
>Last-Modified:  Sat Oct 31 12:24:37 CET 2009
>Originator:     Patroklos Argyroudis
>Release:        8.0-CURRENT
>Organization:
census, inc
>Environment:
N/A
>Description:
Memory leak of pointer sap if the allocation in line 639 fails.
>How-To-Repeat:
N/A
>Fix:
Patch attached.

Patch attached with submission follows:

--- ./sys/cam/scsi/scsi_low.c.orig	2009-08-27 16:57:59.000000000 +0300
+++ ./sys/cam/scsi/scsi_low.c	2009-08-27 17:02:12.000000000 +0300
@@ -638,7 +638,10 @@
 		return ENOMEM;
 	splp = SCSI_LOW_MALLOC(sizeof(*splp));
 	if (splp == NULL)
+	{
+		SCSI_LOW_FREE(sap);
 		return ENOMEM;
+	}
 
 	SCSI_LOW_BZERO(sap, sizeof(*sap));
 	SCSI_LOW_BZERO(splp, sizeof(*splp));


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-scsi 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Aug 31 10:31:12 UTC 2009 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=138376 
State-Changed-From-To: open->patched 
State-Changed-By: brueffer 
State-Changed-When: Thu Oct 22 08:13:19 CEST 2009 
State-Changed-Why:  
Committed, thanks! 


Responsible-Changed-From-To: freebsd-scsi->brueffer 
Responsible-Changed-By: brueffer 
Responsible-Changed-When: Thu Oct 22 08:13:19 CEST 2009 
Responsible-Changed-Why:  
MFC reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=138376 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/138376: commit references a PR
Date: Thu, 22 Oct 2009 06:13:21 +0000 (UTC)

 Author: brueffer
 Date: Thu Oct 22 06:13:07 2009
 New Revision: 198356
 URL: http://svn.freebsd.org/changeset/base/198356
 
 Log:
   Fix a memory leak in an error case.
   
   PR:		138376
   Submitted by:	Patroklos Argyroudis <argp@census-labs.com>
   Reviewed by:	scottl
   MFC after:	1 week
 
 Modified:
   head/sys/cam/scsi/scsi_low.c
 
 Modified: head/sys/cam/scsi/scsi_low.c
 ==============================================================================
 --- head/sys/cam/scsi/scsi_low.c	Thu Oct 22 04:35:32 2009	(r198355)
 +++ head/sys/cam/scsi/scsi_low.c	Thu Oct 22 06:13:07 2009	(r198356)
 @@ -638,7 +638,10 @@ scsi_low_attach_xs(slp)
  		return ENOMEM;
  	splp = SCSI_LOW_MALLOC(sizeof(*splp));
  	if (splp == NULL)
 +	{
 +		SCSI_LOW_FREE(sap);
  		return ENOMEM;
 +	}
  
  	SCSI_LOW_BZERO(sap, sizeof(*sap));
  	SCSI_LOW_BZERO(splp, sizeof(*splp));
 _______________________________________________
 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"
 
State-Changed-From-To: patched->closed 
State-Changed-By: brueffer 
State-Changed-When: Sat Oct 31 12:24:09 CET 2009 
State-Changed-Why:  
MFCs done. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=138376 
>Unformatted:
