hvc console sleep under spinlock
Anton Blanchard
anton at samba.org
Tue Nov 4 16:32:45 EST 2003
Hi Nathan,
> Thanks, patch has been updated accordingly.
Looks good. I just had a thought, is there an uppoer limit on count?
(eg what happens when someone does a 1MB write()?)
> Could this be pushed to mainline through Ameslab, or should it be taken
> to lkml? I ask because the hvc code is not in an arch-specific location
> in the source tree.
These sort of things usually get pushed separately but with the 2.6
lockdown we may not get it in until after 2.6.0.
Anton
> diff -Nru a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
> --- a/drivers/char/hvc_console.c Mon Nov 3 19:10:06 2003
> +++ b/drivers/char/hvc_console.c Mon Nov 3 19:10:06 2003
> @@ -130,24 +130,26 @@
> const unsigned char *buf, int count)
> {
> struct hvc_struct *hp = tty->driver_data;
> - char *p;
> + char *p, *kbuf = NULL;
> int todo, written = 0;
> unsigned long flags;
>
> + if (from_user) {
> + kbuf = kmalloc(count, GFP_KERNEL);
> + if (!kbuf)
> + return -ENOMEM;
> + if (copy_from_user(kbuf, buf, count)) {
> + kfree(kbuf);
> + return -EFAULT;
> + }
> + buf = kbuf;
> + }
> spin_lock_irqsave(&hp->lock, flags);
> while (count > 0 && (todo = N_OUTBUF - hp->n_outbuf) > 0) {
> if (todo > count)
> todo = count;
> p = hp->outbuf + hp->n_outbuf;
> - if (from_user) {
> - todo -= copy_from_user(p, buf, todo);
> - if (todo == 0) {
> - if (written == 0)
> - written = -EFAULT;
> - break;
> - }
> - } else
> - memcpy(p, buf, todo);
> + memcpy(p, buf, todo);
> count -= todo;
> buf += todo;
> hp->n_outbuf += todo;
> @@ -155,7 +157,7 @@
> hvc_push(hp);
> }
> spin_unlock_irqrestore(&hp->lock, flags);
> -
> + kfree(kbuf);
> return written;
> }
>
** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/
More information about the Linuxppc64-dev
mailing list