Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Jan 2004 14:45:02 +0200
From:      Ruslan Ermilov <ru@FreeBSD.org>
To:        Scott Long <scottl@FreeBSD.org>
Cc:        hackers@FreeBSD.org
Subject:   Re: [CHECKER] bugs in FreeBSD
Message-ID:  <20040118124502.GD29936@FreeBSD.org.ua>
In-Reply-To: <Pine.LNX.4.44.0401161607260.26554-100000@Xenon.Stanford.EDU>
References:  <Pine.LNX.4.44.0401161607260.26554-100000@Xenon.Stanford.EDU>

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

--BZaMRJmqxGScZ8Mx
Content-Type: multipart/mixed; boundary="SO98HVl1bnMOfKZd"
Content-Disposition: inline


--SO98HVl1bnMOfKZd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Scott,

Attached is the patch that fixes memory leak according to the below report.

On Fri, Jan 16, 2004 at 04:09:34PM -0800, Paul Twohey wrote:
> ---------------------------------------------------------
> [BUG]  though we should demote things that are not locals.
> /u2/engler/mc/freebsd/sys/i386/compile/GENERIC/../../../dev/ips/ips.c:148=
:ips_add_waiting_command:ERROR:LEAK:148:154: pointer=3Dwaiter from RO=3Dmal=
loc(-1) [s=3D550,pop=3D551,pr=3D1.00] [rank=3Dmed] leaked! [z=3D1.0] [succe=
ss=3D5]
>=20
> 	ips_command_t *command;
> 	ips_wait_list_t *waiter;
> 	unsigned long memflags =3D 0;
> 	if(IPS_NOWAIT_FLAG & flags)
> 		memflags =3D M_NOWAIT;
> Start --->
> 	waiter =3D malloc(sizeof(ips_wait_list_t), M_DEVBUF, memflags);
> 	if(!waiter)
> 		return ENOMEM;
> 	mask =3D splbio();
> 	if(sc->state & IPS_OFFLINE){
> 		splx(mask);
> Error --->
> 		return EIO;
> 	}
> 	command =3D SLIST_FIRST(&sc->free_cmd_list);
> 	if(command && !(sc->state & IPS_TIMEOUT)){
> ---------------------------------------------------------


Cheers,
--=20
Ruslan Ermilov
FreeBSD committer
ru@FreeBSD.org

--SO98HVl1bnMOfKZd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=p

Index: ips.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/ips/ips.c,v
retrieving revision 1.6
diff -u -p -r1.6 ips.c
--- ips.c	27 Nov 2003 08:37:36 -0000	1.6
+++ ips.c	18 Jan 2004 12:41:22 -0000
@@ -163,14 +163,14 @@ static int ips_add_waiting_command(ips_s
 	unsigned long memflags = 0;
 	if(IPS_NOWAIT_FLAG & flags)
 		memflags = M_NOWAIT;
-	waiter = malloc(sizeof(ips_wait_list_t), M_DEVBUF, memflags);
-	if(!waiter)
-		return ENOMEM;
 	mask = splbio();
 	if(sc->state & IPS_OFFLINE){
 		splx(mask);
 		return EIO;
 	}
+	waiter = malloc(sizeof(ips_wait_list_t), M_DEVBUF, memflags);
+	if(!waiter)
+		return ENOMEM;
 	command = SLIST_FIRST(&sc->free_cmd_list);
 	if(command && !(sc->state & IPS_TIMEOUT)){
 		SLIST_REMOVE_HEAD(&sc->free_cmd_list, next);

--SO98HVl1bnMOfKZd--

--BZaMRJmqxGScZ8Mx
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQFACn/OUkv4P6juNwoRAgzfAJ49A3LwT+ht+pW7cJKEjrgZX2n45wCdFBfT
o0FG0H8RCYc/EE8OKAR5aKY=
=U191
-----END PGP SIGNATURE-----

--BZaMRJmqxGScZ8Mx--



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