This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / drivers / char / hvsi.c
index 35babe6..a70a5f5 100644 (file)
@@ -1046,15 +1046,27 @@ static int hvsi_chars_in_buffer(struct tty_struct *tty)
        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);
@@ -1094,6 +1106,9 @@ static int hvsi_write(struct tty_struct *tty,
 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);