X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fisdn%2Fpcbit%2Fdrv.c;h=11c1b0b6e390c1e6f0fd919eb5f4a06706cd2c79;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=e98f9c48c18461a9a56cc5bf6395cf4a1f73b357;hpb=6a77f38946aaee1cd85eeec6cf4229b204c15071;p=linux-2.6.git diff --git a/drivers/isdn/pcbit/drv.c b/drivers/isdn/pcbit/drv.c index e98f9c48c..11c1b0b6e 100644 --- a/drivers/isdn/pcbit/drv.c +++ b/drivers/isdn/pcbit/drv.c @@ -56,10 +56,10 @@ static char* pcbit_devname[MAX_PCBIT_CARDS] = { * prototypes */ -int pcbit_command(isdn_ctrl* ctl); -int pcbit_stat(u_char __user * buf, int len, int, int); -int pcbit_xmit(int driver, int chan, int ack, struct sk_buff *skb); -int pcbit_writecmd(const u_char __user *, int, int, int); +static int pcbit_command(isdn_ctrl* ctl); +static int pcbit_stat(u_char __user * buf, int len, int, int); +static int pcbit_xmit(int driver, int chan, int ack, struct sk_buff *skb); +static int pcbit_writecmd(const u_char __user *, int, int, int); static int set_protocol_running(struct pcbit_dev * dev); @@ -68,21 +68,18 @@ static void pcbit_set_msn(struct pcbit_dev *dev, char *list); static int pcbit_check_msn(struct pcbit_dev *dev, char *msn); -extern void pcbit_deliver(void * data); - int pcbit_init_dev(int board, int mem_base, int irq) { struct pcbit_dev *dev; isdn_if *dev_if; - if ((dev=kmalloc(sizeof(struct pcbit_dev), GFP_KERNEL)) == NULL) + if ((dev=kzalloc(sizeof(struct pcbit_dev), GFP_KERNEL)) == NULL) { printk("pcbit_init: couldn't malloc pcbit_dev struct\n"); return -ENOMEM; } dev_pcbit[board] = dev; - memset(dev, 0, sizeof(struct pcbit_dev)); init_waitqueue_head(&dev->set_running_wq); spin_lock_init(&dev->lock); @@ -106,7 +103,7 @@ int pcbit_init_dev(int board, int mem_base, int irq) return -EACCES; } - dev->b1 = kmalloc(sizeof(struct pcbit_chan), GFP_KERNEL); + dev->b1 = kzalloc(sizeof(struct pcbit_chan), GFP_KERNEL); if (!dev->b1) { printk("pcbit_init: couldn't malloc pcbit_chan struct\n"); iounmap(dev->sh_mem); @@ -115,7 +112,7 @@ int pcbit_init_dev(int board, int mem_base, int irq) return -ENOMEM; } - dev->b2 = kmalloc(sizeof(struct pcbit_chan), GFP_KERNEL); + dev->b2 = kzalloc(sizeof(struct pcbit_chan), GFP_KERNEL); if (!dev->b2) { printk("pcbit_init: couldn't malloc pcbit_chan struct\n"); kfree(dev->b1); @@ -125,11 +122,9 @@ int pcbit_init_dev(int board, int mem_base, int irq) return -ENOMEM; } - memset(dev->b1, 0, sizeof(struct pcbit_chan)); - memset(dev->b2, 0, sizeof(struct pcbit_chan)); dev->b2->id = 1; - INIT_WORK(&dev->qdelivery, pcbit_deliver, dev); + INIT_WORK(&dev->qdelivery, pcbit_deliver); /* * interrupts @@ -238,7 +233,7 @@ void pcbit_terminate(int board) } #endif -int pcbit_command(isdn_ctrl* ctl) +static int pcbit_command(isdn_ctrl* ctl) { struct pcbit_dev *dev; struct pcbit_chan *chan; @@ -330,7 +325,7 @@ static void pcbit_block_timer(unsigned long data) } #endif -int pcbit_xmit(int driver, int chnum, int ack, struct sk_buff *skb) +static int pcbit_xmit(int driver, int chnum, int ack, struct sk_buff *skb) { ushort hdrlen; int refnum, len; @@ -389,7 +384,7 @@ int pcbit_xmit(int driver, int chnum, int ack, struct sk_buff *skb) return len; } -int pcbit_writecmd(const u_char __user *buf, int len, int driver, int channel) +static int pcbit_writecmd(const u_char __user *buf, int len, int driver, int channel) { struct pcbit_dev * dev; int i, j; @@ -561,10 +556,8 @@ void pcbit_l3_receive(struct pcbit_dev * dev, ulong msg, else pcbit_fsm_event(dev, chan, EV_USR_RELEASE_REQ, NULL); - if (cbdata.data.setup.CalledPN) - kfree(cbdata.data.setup.CalledPN); - if (cbdata.data.setup.CallingPN) - kfree(cbdata.data.setup.CallingPN); + kfree(cbdata.data.setup.CalledPN); + kfree(cbdata.data.setup.CallingPN); break; case MSG_CONN_CONF: @@ -713,7 +706,7 @@ static char statbuf[STATBUF_LEN]; static int stat_st = 0; static int stat_end = 0; -int pcbit_stat(u_char __user *buf, int len, int driver, int channel) +static int pcbit_stat(u_char __user *buf, int len, int driver, int channel) { int stat_count; stat_count = stat_end - stat_st; @@ -727,23 +720,27 @@ int pcbit_stat(u_char __user *buf, int len, int driver, int channel) if (stat_st < stat_end) { - copy_to_user(buf, statbuf + stat_st, len); + if (copy_to_user(buf, statbuf + stat_st, len)) + return -EFAULT; stat_st += len; } else { if (len > STATBUF_LEN - stat_st) { - copy_to_user(buf, statbuf + stat_st, - STATBUF_LEN - stat_st); - copy_to_user(buf, statbuf, - len - (STATBUF_LEN - stat_st)); + if (copy_to_user(buf, statbuf + stat_st, + STATBUF_LEN - stat_st)) + return -EFAULT; + if (copy_to_user(buf, statbuf, + len - (STATBUF_LEN - stat_st))) + return -EFAULT; stat_st = len - (STATBUF_LEN - stat_st); } else { - copy_to_user(buf, statbuf + stat_st, len); + if (copy_to_user(buf, statbuf + stat_st, len)) + return -EFAULT; stat_st += len;