* [PATCH] i4l:add some checks for valid drvid and driver pointer
@ 2006-06-29 11:16 Karsten Keil
2006-06-29 11:29 ` Arjan van de Ven
0 siblings, 1 reply; 3+ messages in thread
From: Karsten Keil @ 2006-06-29 11:16 UTC (permalink / raw)
To: Andrew Morton, Linus Torvalds; +Cc: linux-kernel
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: Karsten Keil <kkeil@suse.de>
diff -ur linux-2.6.4.org/drivers/isdn/i4l/isdn_common.c linux-2.6.4/drivers/isdn/i4l/isdn_common.c
--- linux-2.6.4.org/drivers/isdn/i4l/isdn_common.c 2004-03-11 03:55:25.000000000 +0100
+++ linux-2.6.4/drivers/isdn/i4l/isdn_common.c 2004-03-30 18:35:38.000000000 +0200
@@ -341,6 +341,16 @@
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;
@@ -1798,6 +1808,11 @@
{
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) &&
@@ -1813,7 +1828,8 @@
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]);
}
}
---
drivers/isdn/i4l/isdn_common.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
6e755043580f8092019117eef0efcb4aada25e1f
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index b26e509..eb21063 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -340,6 +340,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;
@@ -1903,6 +1913,11 @@ isdn_free_channel(int di, int ch, int us
{
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) &&
@@ -1918,7 +1933,8 @@ isdn_free_channel(int di, int ch, int us
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]);
}
}
--
Karsten Keil
SuSE Labs
ISDN development
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] i4l:add some checks for valid drvid and driver pointer
2006-06-29 11:16 [PATCH] i4l:add some checks for valid drvid and driver pointer Karsten Keil
@ 2006-06-29 11:29 ` Arjan van de Ven
2006-06-29 12:23 ` Karsten Keil
0 siblings, 1 reply; 3+ messages in thread
From: Arjan van de Ven @ 2006-06-29 11:29 UTC (permalink / raw)
To: Karsten Keil; +Cc: Andrew Morton, Linus Torvalds, linux-kernel
On Thu, 2006-06-29 at 13:16 +0200, Karsten Keil wrote:
> 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: Karsten Keil <kkeil@suse.de>
>
> diff -ur linux-2.6.4.org/drivers/isdn/i4l/isdn_common.c linux-2.6.4/drivers/isdn/i4l/isdn_common.c
> --- linux-2.6.4.org/drivers/isdn/i4l/isdn_common.c 2004-03-11 03:55:25.000000000 +0100
> +++ linux-2.6.4/drivers/isdn/i4l/isdn_common.c 2004-03-30 18:35:38.000000000 +0200
> @@ -341,6 +341,16 @@
> 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);
> + }
Hi,
if this is a "legal" condition, you really shouldn't printk about it. If
it's not a normal legal condition, this isn't a fix but a hacky
workaround ;)
Also.. return is not a function, so return 1; is the preferred form,
not return(1)..
Greetings,
Arjan van de Ven
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] i4l:add some checks for valid drvid and driver pointer
2006-06-29 11:29 ` Arjan van de Ven
@ 2006-06-29 12:23 ` Karsten Keil
0 siblings, 0 replies; 3+ messages in thread
From: Karsten Keil @ 2006-06-29 12:23 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: Andrew Morton, Linus Torvalds, linux-kernel
On Thu, Jun 29, 2006 at 01:29:31PM +0200, Arjan van de Ven wrote:
> On Thu, 2006-06-29 at 13:16 +0200, Karsten Keil wrote:
> > 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: Karsten Keil <kkeil@suse.de>
> >
> > diff -ur linux-2.6.4.org/drivers/isdn/i4l/isdn_common.c linux-2.6.4/drivers/isdn/i4l/isdn_common.c
> > --- linux-2.6.4.org/drivers/isdn/i4l/isdn_common.c 2004-03-11 03:55:25.000000000 +0100
> > +++ linux-2.6.4/drivers/isdn/i4l/isdn_common.c 2004-03-30 18:35:38.000000000 +0200
> > @@ -341,6 +341,16 @@
> > 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);
> > + }
>
> Hi,
>
> if this is a "legal" condition, you really shouldn't printk about it. If
> it's not a normal legal condition, this isn't a fix but a hacky
> workaround ;)
>
I also was thinking about removing the printk, they are in my patch for some
time to prove (which runs for long time on my systems) that this are legal
conditions. But you are correct, now it should be removed, no need to spam
syslog.
> Also.. return is not a function, so return 1; is the preferred form,
> not return(1)..
>
OK
(I don't know why, but for me return() looks better, but that pure
private taste)
So I will send a new patch.
--
Karsten Keil
SuSE Labs
ISDN development
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-06-29 12:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-29 11:16 [PATCH] i4l:add some checks for valid drvid and driver pointer Karsten Keil
2006-06-29 11:29 ` Arjan van de Ven
2006-06-29 12:23 ` Karsten Keil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®