aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/i4l/isdn_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/i4l/isdn_common.c')
-rw-r--r--drivers/isdn/i4l/isdn_common.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index 22759c01746a..9f6c6375ff75 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -11,7 +11,6 @@
*
*/
-#include <linux/config.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/poll.h>
@@ -340,6 +339,16 @@ isdn_command(isdn_ctrl *cmd)
printk(KERN_WARNING "isdn_command command(%x) driver -1\n", cmd->command);
return(1);
}
+ if (!dev->drv[cmd->driver]) {
+ printk(KERN_WARNING "isdn_command command(%x) dev->drv[%d] NULL\n",
+ cmd->command, cmd->driver);
+ return(1);
+ }
+ if (!dev->drv[cmd->driver]->interface) {
+ printk(KERN_WARNING "isdn_command command(%x) dev->drv[%d]->interface NULL\n",
+ cmd->command, cmd->driver);
+ return(1);
+ }
if (cmd->command == ISDN_CMD_SETL2) {
int idx = isdn_dc2minor(cmd->driver, cmd->arg & 255);
unsigned long l2prot = (cmd->arg >> 8) & 255;
@@ -933,7 +942,7 @@ isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack)
count_put = count_pull;
if(count_put > 1)
tty_insert_flip_string(tty, skb->data, count_put - 1);
- last = skb->data[count_put] - 1;
+ last = skb->data[count_put - 1];
len -= count_put;
#ifdef CONFIG_ISDN_AUDIO
}
@@ -1177,9 +1186,8 @@ isdn_write(struct file *file, const char __user *buf, size_t count, loff_t * off
goto out;
}
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]);
- retval = count;
goto out;
}
if (minor <= ISDN_MINOR_CTRLMAX) {
@@ -1904,6 +1912,11 @@ isdn_free_channel(int di, int ch, int usage)
{
int i;
+ if ((di < 0) || (ch < 0)) {
+ printk(KERN_WARNING "%s: called with invalid drv(%d) or channel(%d)\n",
+ __FUNCTION__, di, ch);
+ return;
+ }
for (i = 0; i < ISDN_MAX_CHANNELS; i++)
if (((!usage) || ((dev->usage[i] & ISDN_USAGE_MASK) == usage)) &&
(dev->drvmap[i] == di) &&
@@ -1919,7 +1932,8 @@ isdn_free_channel(int di, int ch, int usage)
dev->v110[i] = NULL;
// 20.10.99 JIM, try to reinitialize v110 !
isdn_info_update();
- skb_queue_purge(&dev->drv[di]->rpqueue[ch]);
+ if (dev->drv[di])
+ skb_queue_purge(&dev->drv[di]->rpqueue[ch]);
}
}
@@ -1951,9 +1965,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);
if (!skb)
- return 0;
+ return -ENOMEM;
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);
if (ret <= 0)
dev_kfree_skb(skb);