From e3f4d3b5e816459d58a4c5e82d008d1365b00316 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Sun, 30 Dec 2001 17:34:19 +0000 Subject: Reduce kernel stack usage of ccdinit() by MAXPATHLEN by using MALLOC(9). Submitted by: Maxim Konovalov MFC after: 1 week --- sys/dev/ccd/ccd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/ccd/ccd.c b/sys/dev/ccd/ccd.c index dc9ea96d04919..fcf968e06a673 100644 --- a/sys/dev/ccd/ccd.c +++ b/sys/dev/ccd/ccd.c @@ -394,7 +394,7 @@ ccdinit(struct ccd_s *cs, char **cpaths, struct thread *td) 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 @@ ccdinit(struct ccd_s *cs, char **cpaths, struct thread *td) */ maxsecsize = 0; minsize = 0; + tmppath = malloc(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,6 @@ ccdinit(struct ccd_s *cs, char **cpaths, struct thread *td) /* * Copy in the pathname of the component. */ - bzero(tmppath, sizeof(tmppath)); /* sanity */ if ((error = copyinstr(cpaths[ix], tmppath, MAXPATHLEN, &ci->ci_pathlen)) != 0) { #ifdef DEBUG @@ -488,6 +488,9 @@ ccdinit(struct ccd_s *cs, char **cpaths, struct thread *td) cs->sc_size += size; } + free(tmppath, M_DEVBUF); + tmppath = NULL; + /* * Don't allow the interleave to be smaller than * the biggest component sector. @@ -577,6 +580,8 @@ fail: ci--; free(ci->ci_path, M_DEVBUF); } + if (tmppath != NULL) + free(tmppath, M_DEVBUF); free(cs->sc_cinfo, M_DEVBUF); return (error); } -- cgit v1.3