return hp->n_outbuf;
}
-static int hvsi_write(struct tty_struct *tty,
+static int hvsi_write(struct tty_struct *tty, int from_user,
const unsigned char *buf, int count)
{
struct hvsi_struct *hp = tty->driver_data;
const char *source = buf;
+ char *kbuf = NULL;
unsigned long flags;
int total = 0;
int origcount = count;
+ if (from_user) {
+ kbuf = kmalloc(count, GFP_KERNEL);
+ if (kbuf == NULL)
+ return -ENOMEM;
+ if (copy_from_user(kbuf, buf, count)) {
+ kfree(kbuf);
+ return -EFAULT;
+ }
+ source = kbuf;
+ }
+
spin_lock_irqsave(&hp->lock, flags);
pr_debug("%s: %i chars in buffer\n", __FUNCTION__, hp->n_outbuf);
out:
spin_unlock_irqrestore(&hp->lock, flags);
+ if (from_user)
+ kfree(kbuf);
+
if (total != origcount)
pr_debug("%s: wanted %i, only wrote %i\n", __FUNCTION__, origcount,
total);