X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fisdn%2Fhardware%2Feicon%2Fdivasproc.c;h=6a4373a4f1e8c7715a274eff93db299fdffa8970;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=abf80d82e704a24ce7e9d7774f4a84a28839e9c6;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/isdn/hardware/eicon/divasproc.c b/drivers/isdn/hardware/eicon/divasproc.c index abf80d82e..6a4373a4f 100644 --- a/drivers/isdn/hardware/eicon/divasproc.c +++ b/drivers/isdn/hardware/eicon/divasproc.c @@ -1,4 +1,4 @@ -/* $Id: divasproc.c,v 1.19 2004/03/21 17:26:01 armin Exp $ +/* $Id: divasproc.c,v 1.19.4.3 2005/01/31 12:22:20 armin Exp $ * * Low level driver for Eicon DIVA Server ISDN cards. * /proc functions @@ -10,12 +10,12 @@ * of the GNU General Public License, incorporated herein by reference. */ -#include #include #include #include #include #include +#include #include "platform.h" #include "debuglib.h" @@ -54,7 +54,7 @@ extern struct proc_dir_entry *proc_net_eicon; static struct proc_dir_entry *divas_proc_entry = NULL; static ssize_t -divas_read(struct file *file, char *buf, size_t count, loff_t * off) +divas_read(struct file *file, char __user *buf, size_t count, loff_t * off) { int len = 0; int cadapter; @@ -63,8 +63,6 @@ divas_read(struct file *file, char *buf, size_t count, loff_t * off) if (*off) return 0; - if (off != &file->f_pos) - return -ESPIPE; divas_get_version(tmpbuf); if (copy_to_user(buf + len, &tmpbuf, strlen(tmpbuf))) @@ -95,7 +93,7 @@ divas_read(struct file *file, char *buf, size_t count, loff_t * off) } static ssize_t -divas_write(struct file *file, const char *buf, size_t count, loff_t * off) +divas_write(struct file *file, const char __user *buf, size_t count, loff_t * off) { return (-ENODEV); } @@ -107,7 +105,7 @@ static unsigned int divas_poll(struct file *file, poll_table * wait) static int divas_open(struct inode *inode, struct file *file) { - return (0); + return nonseekable_open(inode, file); } static int divas_close(struct inode *inode, struct file *file) @@ -151,14 +149,17 @@ void remove_divas_proc(void) ** write group_optimization */ static int -write_grp_opt(struct file *file, const char *buffer, unsigned long count, +write_grp_opt(struct file *file, const char __user *buffer, unsigned long count, void *data) { diva_os_xdi_adapter_t *a = (diva_os_xdi_adapter_t *) data; PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; if ((count == 1) || (count == 2)) { - switch (buffer[0]) { + char c; + if (get_user(c, buffer)) + return -EFAULT; + switch (c) { case '0': IoAdapter->capi_cfg.cfg_1 &= ~DIVA_XDI_CAPI_CFG_1_GROUP_POPTIMIZATION_ON; @@ -179,14 +180,17 @@ write_grp_opt(struct file *file, const char *buffer, unsigned long count, ** write dynamic_l1_down */ static int -write_d_l1_down(struct file *file, const char *buffer, unsigned long count, +write_d_l1_down(struct file *file, const char __user *buffer, unsigned long count, void *data) { diva_os_xdi_adapter_t *a = (diva_os_xdi_adapter_t *) data; PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; if ((count == 1) || (count == 2)) { - switch (buffer[0]) { + char c; + if (get_user(c, buffer)) + return -EFAULT; + switch (c) { case '0': IoAdapter->capi_cfg.cfg_1 &= ~DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON; @@ -256,14 +260,21 @@ read_grp_opt(char *page, char **start, off_t off, int count, int *eof, ** info write */ static int -info_write(struct file *file, const char *buffer, unsigned long count, +info_write(struct file *file, const char __user *buffer, unsigned long count, void *data) { diva_os_xdi_adapter_t *a = (diva_os_xdi_adapter_t *) data; PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; + char c[4]; + + if (count <= 4) + return -EINVAL; + + if (copy_from_user(c, buffer, 4)) + return -EFAULT; /* this is for test purposes only */ - if ((count > 4) && (!memcmp(buffer, "trap", 4))) { + if (!memcmp(c, "trap", 4)) { (*(IoAdapter->os_trap_nfy_Fnc)) (IoAdapter, IoAdapter->ANum); return (count); } @@ -369,7 +380,7 @@ int create_adapter_proc(diva_os_xdi_adapter_t * a) char tmp[16]; sprintf(tmp, "%s%d", adapter_dir_name, a->controller); - if (!(de = create_proc_entry(tmp, S_IFDIR, proc_net_eicon))) + if (!(de = proc_mkdir(tmp, proc_net_eicon))) return (0); a->proc_adapter_dir = (void *) de;