From e10c44e8a2a53f2dfb979d3ebc8549a509bdfef1 Mon Sep 17 00:00:00 2001 From: "Brian J. Murrell" Date: Tue, 5 Apr 2011 01:16:51 -0400 Subject: [PATCH] LU-175 don't allocate kernbuf on the stack On i686, allocating a kernbuf of 1K on the stack causes a compiler error: lustre/mdt/mdt_lproc.c:255: error: the frame size of 1040 bytes is larger than 1024 bytes Signed-off-by: Brian J. Murrell Change-Id: I91e4fc39fa6bdc6b6d7937263520b1dfce8c4746 Reviewed-on: http://review.whamcloud.com/401 Reviewed-by: Oleg Drokin Tested-by: Hudson Reviewed-by: Lai Siyao Reviewed-by: Johann Lombardi --- lustre/mdt/mdt_lproc.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index c2929c6..8fa813d 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -225,17 +225,18 @@ static int lprocfs_wr_identity_upcall(struct file *file, const char *buffer, struct obd_device *obd = data; struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); struct upcall_cache *hash = mdt->mdt_identity_cache; - char kernbuf[UC_CACHE_UPCALL_MAXPATH] = { '\0' }; + int rc; + char *kernbuf; if (count >= UC_CACHE_UPCALL_MAXPATH) { CERROR("%s: identity upcall too long\n", obd->obd_name); return -EINVAL; } - - if (cfs_copy_from_user(kernbuf, buffer, - min_t(unsigned long, count, - UC_CACHE_UPCALL_MAXPATH - 1))) - return -EFAULT; + OBD_ALLOC(kernbuf, count + 1); + if (kernbuf == NULL) + GOTO(failed, rc = -ENOMEM); + if (cfs_copy_from_user(kernbuf, buffer, count)) + GOTO(failed, rc = -EFAULT); /* Remove any extraneous bits from the upcall (e.g. linefeeds) */ cfs_write_lock(&hash->uc_upcall_rwlock); @@ -251,7 +252,13 @@ static int lprocfs_wr_identity_upcall(struct file *file, const char *buffer, "cause unexpected \"EACCESS\"\n", obd->obd_name); CWARN("%s: identity upcall set to %s\n", obd->obd_name, hash->uc_upcall); - return count; + OBD_FREE(kernbuf, count + 1); + RETURN(count); + + failed: + if (kernbuf) + OBD_FREE(kernbuf, count + 1); + RETURN(rc); } static int lprocfs_wr_identity_flush(struct file *file, const char *buffer, -- 1.8.3.1