diff options
Diffstat (limited to 'drivers/isdn/capi/kcapi.c')
| -rw-r--r-- | drivers/isdn/capi/kcapi.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c index 7168778fbbe1..e8f7e52354bc 100644 --- a/drivers/isdn/capi/kcapi.c +++ b/drivers/isdn/capi/kcapi.c @@ -32,7 +32,7 @@ #include <linux/mutex.h> #include <linux/rcupdate.h> -static int showcapimsgs = 0; +static int showcapimsgs; static struct workqueue_struct *kcapi_wq; module_param(showcapimsgs, uint, 0); @@ -480,6 +480,11 @@ int detach_capi_ctr(struct capi_ctr *ctr) ctr_down(ctr, CAPI_CTR_DETACHED); + if (ctr->cnr < 1 || ctr->cnr - 1 >= CAPI_MAXCONTR) { + err = -EINVAL; + goto unlock_out; + } + if (capi_controller[ctr->cnr - 1] != ctr) { err = -EINVAL; goto unlock_out; @@ -721,13 +726,13 @@ u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb) * Return value: CAPI result code */ -u16 capi20_get_manufacturer(u32 contr, u8 *buf) +u16 capi20_get_manufacturer(u32 contr, u8 buf[CAPI_MANUFACTURER_LEN]) { struct capi_ctr *ctr; u16 ret; if (contr == 0) { - strncpy(buf, capi_manufakturer, CAPI_MANUFACTURER_LEN); + strscpy_pad(buf, capi_manufakturer, CAPI_MANUFACTURER_LEN); return CAPI_NOERROR; } @@ -735,7 +740,7 @@ u16 capi20_get_manufacturer(u32 contr, u8 *buf) ctr = get_capi_ctr_by_nr(contr); if (ctr && ctr->state == CAPI_CTR_RUNNING) { - strncpy(buf, ctr->manu, CAPI_MANUFACTURER_LEN); + strscpy_pad(buf, ctr->manu, CAPI_MANUFACTURER_LEN); ret = CAPI_NOERROR; } else ret = CAPI_REGNOTINSTALLED; @@ -787,13 +792,13 @@ u16 capi20_get_version(u32 contr, struct capi_version *verp) * Return value: CAPI result code */ -u16 capi20_get_serial(u32 contr, u8 *serial) +u16 capi20_get_serial(u32 contr, u8 serial[CAPI_SERIAL_LEN]) { struct capi_ctr *ctr; u16 ret; if (contr == 0) { - strlcpy(serial, driver_serial, CAPI_SERIAL_LEN); + strscpy(serial, driver_serial, CAPI_SERIAL_LEN); return CAPI_NOERROR; } @@ -801,7 +806,7 @@ u16 capi20_get_serial(u32 contr, u8 *serial) ctr = get_capi_ctr_by_nr(contr); if (ctr && ctr->state == CAPI_CTR_RUNNING) { - strlcpy(serial, ctr->serial, CAPI_SERIAL_LEN); + strscpy(serial, ctr->serial, CAPI_SERIAL_LEN); ret = CAPI_NOERROR; } else ret = CAPI_REGNOTINSTALLED; @@ -902,7 +907,7 @@ int __init kcapi_init(void) { int err; - kcapi_wq = alloc_workqueue("kcapi", 0, 0); + kcapi_wq = alloc_workqueue("kcapi", WQ_PERCPU, 0); if (!kcapi_wq) return -ENOMEM; @@ -912,13 +917,16 @@ int __init kcapi_init(void) return err; } - kcapi_proc_init(); + if (IS_ENABLED(CONFIG_PROC_FS)) + kcapi_proc_init(); + return 0; } void kcapi_exit(void) { - kcapi_proc_exit(); + if (IS_ENABLED(CONFIG_PROC_FS)) + kcapi_proc_exit(); cdebug_exit(); destroy_workqueue(kcapi_wq); |
