Commit d20d04bc authored by Jesper Juhl's avatar Jesper Juhl Committed by Linus Torvalds

[PATCH] ISDN: correctly handle isdn_writebuf_stub() errors

isdn_writebuf_stub() forgets to detect memory allocation and uaccess errors.
And when that's fixed, if a error happens the caller will just keep on
looping.

So change the caller to detect the error, and to return it.
Signed-off-by: default avatarJesper Juhl <jesper.juhl@gmail.com>
Cc: Karsten Keil <kkeil@suse.de>
Signed-off-by: default avatarTilman Schmidt <tilman@imap.cc>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 94a6735c
...@@ -1177,9 +1177,8 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off ...@@ -1177,9 +1177,8 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off
goto out; goto out;
} }
chidx = isdn_minor2chan(minor); chidx = isdn_minor2chan(minor);
while (isdn_writebuf_stub(drvidx, chidx, buf, count) != count) while ((retval = isdn_writebuf_stub(drvidx, chidx, buf, count)) == 0)
interruptible_sleep_on(&dev->drv[drvidx]->snd_waitq[chidx]); interruptible_sleep_on(&dev->drv[drvidx]->snd_waitq[chidx]);
retval = count;
goto out; goto out;
} }
if (minor <= ISDN_MINOR_CTRLMAX) { if (minor <= ISDN_MINOR_CTRLMAX) {
...@@ -1951,9 +1950,10 @@ isdn_writebuf_stub(int drvidx, int chan, const u_char __user * buf, int len) ...@@ -1951,9 +1950,10 @@ isdn_writebuf_stub(int drvidx, int chan, const u_char __user * buf, int len)
struct sk_buff *skb = alloc_skb(hl + len, GFP_ATOMIC); struct sk_buff *skb = alloc_skb(hl + len, GFP_ATOMIC);
if (!skb) if (!skb)
return 0; return -ENOMEM;
skb_reserve(skb, hl); skb_reserve(skb, hl);
copy_from_user(skb_put(skb, len), buf, len); if (copy_from_user(skb_put(skb, len), buf, len))
return -EFAULT;
ret = dev->drv[drvidx]->interface->writebuf_skb(drvidx, chan, 1, skb); ret = dev->drv[drvidx]->interface->writebuf_skb(drvidx, chan, 1, skb);
if (ret <= 0) if (ret <= 0)
dev_kfree_skb(skb); dev_kfree_skb(skb);
......
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