提交 09fca29d 编写于 作者: K Karsten Keil 提交者: Linus Torvalds

[PATCH] i4l:add some checks for valid drvid and driver pointer

If all drivers go away before all ISDN network interfaces are closed we got
a OOps on removing interfaces, this patch avoid it.
Signed-off-by: NKarsten Keil <kkeil@suse.de>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 0f6c10ea
...@@ -340,6 +340,16 @@ isdn_command(isdn_ctrl *cmd) ...@@ -340,6 +340,16 @@ isdn_command(isdn_ctrl *cmd)
printk(KERN_WARNING "isdn_command command(%x) driver -1\n", cmd->command); printk(KERN_WARNING "isdn_command command(%x) driver -1\n", cmd->command);
return(1); 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) { if (cmd->command == ISDN_CMD_SETL2) {
int idx = isdn_dc2minor(cmd->driver, cmd->arg & 255); int idx = isdn_dc2minor(cmd->driver, cmd->arg & 255);
unsigned long l2prot = (cmd->arg >> 8) & 255; unsigned long l2prot = (cmd->arg >> 8) & 255;
...@@ -1903,6 +1913,11 @@ isdn_free_channel(int di, int ch, int usage) ...@@ -1903,6 +1913,11 @@ isdn_free_channel(int di, int ch, int usage)
{ {
int i; 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++) for (i = 0; i < ISDN_MAX_CHANNELS; i++)
if (((!usage) || ((dev->usage[i] & ISDN_USAGE_MASK) == usage)) && if (((!usage) || ((dev->usage[i] & ISDN_USAGE_MASK) == usage)) &&
(dev->drvmap[i] == di) && (dev->drvmap[i] == di) &&
...@@ -1918,7 +1933,8 @@ isdn_free_channel(int di, int ch, int usage) ...@@ -1918,7 +1933,8 @@ isdn_free_channel(int di, int ch, int usage)
dev->v110[i] = NULL; dev->v110[i] = NULL;
// 20.10.99 JIM, try to reinitialize v110 ! // 20.10.99 JIM, try to reinitialize v110 !
isdn_info_update(); isdn_info_update();
skb_queue_purge(&dev->drv[di]->rpqueue[ch]); if (dev->drv[di])
skb_queue_purge(&dev->drv[di]->rpqueue[ch]);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册