i4l:add some checks for valid drvid and driver pointer
PATCH 1/1 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.
drivers/isdn/i4l/isdn_common.c +17 -1
@@ -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
drivers/isdn/i4l/isdn_common.c +17 -1
@@ -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]); } }
Signature · 3 lines
Karsten Keil SuSE Labs ISDN development
Quoted 9 lines · Karsten Keil
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 <[email protected]>diff -ur
linux-2.6.4.org/drivers/isdn/i4l/isdn_common.clinux-2.6.4/drivers/isdn/i4l/isdn_common.c
drivers/isdn/i4l/isdn_common.c line 348
Quoted 8 lines
drivers/isdn/i4l/isdn_common.c +5
-0@@ -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
Quoted 21 lines · Arjan van de Ven
Quoted 9 lines · Karsten Keil
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 <[email protected]>diff -ur
linux-2.6.4.org/drivers/isdn/i4l/isdn_common.clinux-2.6.4/drivers/isdn/i4l/isdn_common.cdrivers/isdn/i4l/isdn_common.c line 348
Quoted 8 lines
drivers/isdn/i4l/isdn_common.c +5
-0@@ -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,
Quoted 4 lines
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.
Quoted 3 lines
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.
Signature · 3 lines
Karsten Keil SuSE Labs ISDN development