Date: Sun, 30 Dec 2001 15:28:23 +0300 (MSK) From: Maxim Konovalov <maxim@macomnet.ru> To: Poul-Henning Kamp <phk@FreeBSD.ORG> Cc: current@FreeBSD.ORG Subject: Re: Junior Kernel Hacker Task: ccdinit stack usage. Message-ID: <20011230152238.H14718-100000@news1.macomnet.ru> In-Reply-To: <22398.1009711403@critter.freebsd.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011230152238.H14718-100000>