Commit 9174121c authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] cpqarray.c: fix stack usage

From: Jorn Engel <joern@wohnheim.fh-wedel.de>

Reduce stack usage in the cpqarray ioctl byt several hundred bytes.
parent 5e173955
...@@ -1028,7 +1028,7 @@ static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -1028,7 +1028,7 @@ static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
int diskinfo[4]; int diskinfo[4];
struct hd_geometry *geo = (struct hd_geometry *)arg; struct hd_geometry *geo = (struct hd_geometry *)arg;
ida_ioctl_t *io = (ida_ioctl_t*)arg; ida_ioctl_t *io = (ida_ioctl_t*)arg;
ida_ioctl_t my_io; ida_ioctl_t *my_io;
switch(cmd) { switch(cmd) {
case HDIO_GETGEO: case HDIO_GETGEO:
...@@ -1051,12 +1051,24 @@ static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -1051,12 +1051,24 @@ static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
return -EFAULT; return -EFAULT;
return 0; return 0;
case IDAPASSTHRU: case IDAPASSTHRU:
if (!capable(CAP_SYS_RAWIO)) return -EPERM; if (!capable(CAP_SYS_RAWIO))
if (copy_from_user(&my_io, io, sizeof(my_io))) return -EPERM;
return -EFAULT; my_io = kmalloc(sizeof(ida_ioctl_t), GFP_KERNEL);
error = ida_ctlr_ioctl(host, drv - host->drv, &my_io); if (!my_io)
if (error) return error; return -ENOMEM;
return copy_to_user(io, &my_io, sizeof(my_io)) ? -EFAULT : 0; error = -EFAULT;
if (copy_from_user(my_io, io, sizeof(*my_io)))
goto out_passthru;
error = ida_ctlr_ioctl(host, drv - host->drv, my_io);
if (error)
goto out_passthru;
error = -EFAULT;
if (copy_to_user(io, &my_io, sizeof(*my_io)))
goto out_passthru;
error = 0;
out_passthru:
kfree(my_io);
return error;
case IDAGETCTLRSIG: case IDAGETCTLRSIG:
if (!arg) return -EINVAL; if (!arg) return -EINVAL;
put_user(host->ctlr_sig, (int*)arg); put_user(host->ctlr_sig, (int*)arg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment