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 <brian@whamcloud.com>
Change-Id: I91e4fc39fa6bdc6b6d7937263520b1dfce8c4746
Reviewed-on: http://review.whamcloud.com/401
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: Hudson
Reviewed-by: Lai Siyao <laisiyao@whamcloud.com>
Reviewed-by: Johann Lombardi <johann@whamcloud.com>
struct obd_device *obd = data;
struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
struct upcall_cache *hash = mdt->mdt_identity_cache;
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 (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);
/* Remove any extraneous bits from the upcall (e.g. linefeeds) */
cfs_write_lock(&hash->uc_upcall_rwlock);
"cause unexpected \"EACCESS\"\n", obd->obd_name);
CWARN("%s: identity upcall set to %s\n", obd->obd_name, hash->uc_upcall);
"cause unexpected \"EACCESS\"\n", obd->obd_name);
CWARN("%s: identity upcall set to %s\n", obd->obd_name, hash->uc_upcall);
+ 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,
}
static int lprocfs_wr_identity_flush(struct file *file, const char *buffer,