diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-04-06 18:00:07 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-04-09 15:16:50 -0400 |
commit | 7c51d177f0eac50a85abc19e60e79c1dc58955d9 (patch) | |
tree | 1370f793f854b44d9be42bfb8e6ea9ec1d237f30 /drivers/staging | |
parent | 434b5a2e2dfd2a15bde68ed7ed2d4150eceb04e0 (diff) | |
download | op-kernel-dev-7c51d177f0eac50a85abc19e60e79c1dc58955d9.zip op-kernel-dev-7c51d177f0eac50a85abc19e60e79c1dc58955d9.tar.gz |
vt6656: slightly sanitized reading config
Just reading - parsing the results is left alone (and unspeakably
lousy).
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/vt6656/main_usb.c | 63 |
1 files changed, 20 insertions, 43 deletions
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index a5063a6..457d91c 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -46,6 +46,7 @@ */ #undef __NO_VERSION__ +#include <linux/file.h> #include "device.h" #include "card.h" #include "baseband.h" @@ -1316,53 +1317,29 @@ static int Config_FileGetParameter(unsigned char *string, /* if read fails, return NULL, or return data pointer */ static unsigned char *Config_FileOperation(struct vnt_private *pDevice) { - unsigned char *config_path = CONFIG_PATH; - unsigned char *buffer = NULL; - struct file *filp=NULL; - mm_segment_t old_fs = get_fs(); + unsigned char *buffer = kmalloc(1024, GFP_KERNEL); + struct file *file; - int result = 0; - - set_fs (KERNEL_DS); - - /* open file */ - filp = filp_open(config_path, O_RDWR, 0); - if (IS_ERR(filp)) { - printk("Config_FileOperation file Not exist\n"); - result=-1; - goto error2; - } - - if(!(filp->f_op) || !(filp->f_op->read) ||!(filp->f_op->write)) { - printk("file %s is not read or writeable?\n",config_path); - result = -1; - goto error1; - } - - buffer = kmalloc(1024, GFP_KERNEL); - if(buffer==NULL) { - printk("allocate mem for file fail?\n"); - result = -1; - goto error1; - } - - if(filp->f_op->read(filp, buffer, 1024, &filp->f_pos)<0) { - printk("read file error?\n"); - result = -1; - } + if (!buffer) { + printk("allocate mem for file fail?\n"); + return NULL; + } -error1: - if(filp_close(filp,NULL)) - printk("Config_FileOperation:close file fail\n"); + file = filp_open(CONFIG_PATH, O_RDONLY, 0); + if (IS_ERR(file)) { + kfree(buffer); + printk("Config_FileOperation file Not exist\n"); + return NULL; + } -error2: - set_fs (old_fs); + if (kernel_read(file, 0, buffer, 1024) < 0) { + printk("read file error?\n"); + kfree(buffer); + buffer = NULL; + } -if(result!=0) { - kfree(buffer); - buffer=NULL; -} - return buffer; + fput(file); + return buffer; } /* return --->-1:fail; >=0:successful */ |