From owner-freebsd-current Sun Dec 30 4:28:43 2001 Delivered-To: freebsd-current@freebsd.org Received: from relay1.macomnet.ru (relay1.macomnet.ru [195.128.64.10]) by hub.freebsd.org (Postfix) with ESMTP id 3D74137B43F; Sun, 30 Dec 2001 04:28:25 -0800 (PST) Received: from news1.macomnet.ru (maxim@news1.macomnet.ru [195.128.64.14]) by relay1.macomnet.ru (8.11.3/8.11.3) with ESMTP id fBUCSNY4191169; Sun, 30 Dec 2001 15:28:23 +0300 (MSK) Date: Sun, 30 Dec 2001 15:28:23 +0300 (MSK) From: Maxim Konovalov To: Poul-Henning Kamp Cc: current@FreeBSD.ORG Subject: Re: Junior Kernel Hacker Task: ccdinit stack usage. In-Reply-To: <22398.1009711403@critter.freebsd.dk> Message-ID: <20011230152238.H14718-100000@news1.macomnet.ru> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hello, On 12:23+0100, Dec 30, 2001, Poul-Henning Kamp wrote: > > sys/dev/ccd/ccd.c:ccdinit() has a couple of very large items on > the stack. > > Rewrite ccdinit() to allocate them with MALLOC(9) instead. tmppath is a rather big one but I can't find the second item. What about this patch: Index: ccd.c =================================================================== RCS file: /home/ncvs/src/sys/dev/ccd/ccd.c,v retrieving revision 1.95 diff -u -r1.95 ccd.c --- ccd.c 17 Nov 2001 00:46:08 -0000 1.95 +++ ccd.c 30 Dec 2001 12:15:25 -0000 @@ -394,7 +394,7 @@ int maxsecsize; struct partinfo dpart; struct ccdgeom *ccg = &cs->sc_geom; - char tmppath[MAXPATHLEN]; + char *tmppath = NULL; int error = 0; #ifdef DEBUG @@ -414,6 +414,7 @@ */ maxsecsize = 0; minsize = 0; + MALLOC(tmppath, char *, MAXPATHLEN, M_DEVBUF, M_WAITOK); for (ix = 0; ix < cs->sc_nccdisks; ix++) { vp = cs->sc_vpp[ix]; ci = &cs->sc_cinfo[ix]; @@ -422,7 +423,7 @@ /* * Copy in the pathname of the component. */ - bzero(tmppath, sizeof(tmppath)); /* sanity */ + bzero(tmppath, MAXPATHLEN); /* sanity */ if ((error = copyinstr(cpaths[ix], tmppath, MAXPATHLEN, &ci->ci_pathlen)) != 0) { #ifdef DEBUG @@ -487,6 +488,8 @@ ci->ci_size = size; cs->sc_size += size; } + + FREE(tmppath, M_DEVBUF); /* * Don't allow the interleave to be smaller than -- Maxim Konovalov, MAcomnet, Internet-Intranet Dept., system engineer phone: +7 (095) 796-9079, mailto: maxim@macomnet.ru To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message