patch-2.4.6 linux/drivers/sound/emu10k1/audio.c
Next file: linux/drivers/sound/gus_wave.c
Previous file: linux/drivers/sound/cs46xxpm-24.h
Back to the patch index
Back to the overall index
- Lines: 67
- Date:
Mon Jul 2 13:56:41 2001
- Orig file:
v2.4.5/linux/drivers/sound/emu10k1/audio.c
- Orig date:
Wed Apr 18 11:49:11 2001
diff -u --recursive --new-file v2.4.5/linux/drivers/sound/emu10k1/audio.c linux/drivers/sound/emu10k1/audio.c
@@ -903,33 +903,46 @@
case SNDCTL_COPR_LOAD:
{
- copr_buffer buf;
+ copr_buffer *buf;
u32 i;
+ int ret = -EFAULT;
DPF(2, "SNDCTL_COPR_LOAD:\n");
+
+ buf = kmalloc(sizeof(copr_buffer), GFP_KERNEL);
+ if(buf == NULL)
+ return -ENOMEM;
+
+ if (copy_from_user(buf, (copr_buffer *) arg, sizeof(buf)))
+ goto fail;
+
+ if ((buf->command != 1) && (buf->command != 2))
+ {
+ ret = -EINVAL;
+ goto fail;
+ }
- if (copy_from_user(&buf, (copr_buffer *) arg, sizeof(buf)))
- return -EFAULT;
-
- if ((buf.command != 1) && (buf.command != 2))
- return -EINVAL;
-
- if ((buf.offs < 0x100)
- || (buf.offs < 0x000)
- || (buf.offs + buf.len > 0x800) || (buf.len > 1000))
- return -EINVAL;
-
- if (buf.command == 1) {
- for (i = 0; i < buf.len; i++)
- ((u32 *) buf.data)[i] = sblive_readptr(wave_dev->card, buf.offs + i, 0);
+ if ((buf->offs < 0x100)
+ || (buf->offs < 0x000)
+ || (buf->offs + buf->len > 0x800) || (buf->len > 1000))
+ {
+ ret = -EINVAL;
+ goto fail;
+ }
+ if (buf->command == 1) {
+ for (i = 0; i < buf->len; i++)
+ ((u32 *) buf->data)[i] = sblive_readptr(wave_dev->card, buf->offs + i, 0);
- if (copy_to_user((copr_buffer *) arg, &buf, sizeof(buf)))
- return -EFAULT;
+ if (copy_to_user((copr_buffer *) arg, buf, sizeof(buf)))
+ goto fail;
} else {
- for (i = 0; i < buf.len; i++)
- sblive_writeptr(wave_dev->card, buf.offs + i, 0, ((u32 *) buf.data)[i]);
+ for (i = 0; i < buf->len; i++)
+ sblive_writeptr(wave_dev->card, buf->offs + i, 0, ((u32 *) buf->data)[i]);
}
- break;
+ ret = 0;
+ fail:
+ kfree(buf);
+ return ret;
}
default: /* Default is unrecognized command */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)