aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-07-22 13:02:01 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-29 13:24:20 -0400
commit32aecdd36528449cec34e6e63dcd5f0221ca7b43 (patch)
tree2643f5ab53f1e1e934cef578e6f6b4cf1e0ca048 /drivers/staging
parente4fad8e5d220e3dfb1050eee752ee5058f29a232 (diff)
slightly reduce idiocy in drivers/staging/bcm/Misc.c
a) vfs_llseek() does *not* access userland pointers of any kind b) neither does filp_close(), for that matter c) ... nor filp_open() d) vfs_read() does, but we do have a wrapper for that (kernel_read()), so there's no need to reinvent it. e) passing current->files to filp_close() on something that never had been in descriptor table is pointless. ISAGN: voodoo dolls to be used on voodoo programmers... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/bcm/Misc.c31
1 files changed, 5 insertions, 26 deletions
diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c
index 8223a6913fc5..7067af2fa610 100644
--- a/drivers/staging/bcm/Misc.c
+++ b/drivers/staging/bcm/Misc.c
@@ -157,12 +157,7 @@ static int create_worker_threads(PMINI_ADAPTER psAdapter)
157 157
158static struct file *open_firmware_file(PMINI_ADAPTER Adapter, const char *path) 158static struct file *open_firmware_file(PMINI_ADAPTER Adapter, const char *path)
159{ 159{
160 struct file *flp = NULL; 160 struct file *flp = filp_open(path, O_RDONLY, S_IRWXU);
161 mm_segment_t oldfs;
162 oldfs = get_fs();
163 set_fs(get_ds());
164 flp = filp_open(path, O_RDONLY, S_IRWXU);
165 set_fs(oldfs);
166 if (IS_ERR(flp)) { 161 if (IS_ERR(flp)) {
167 pr_err(DRV_NAME "Unable To Open File %s, err %ld", path, PTR_ERR(flp)); 162 pr_err(DRV_NAME "Unable To Open File %s, err %ld", path, PTR_ERR(flp));
168 flp = NULL; 163 flp = NULL;
@@ -183,14 +178,12 @@ static int BcmFileDownload(PMINI_ADAPTER Adapter, const char *path, unsigned int
183{ 178{
184 int errorno = 0; 179 int errorno = 0;
185 struct file *flp = NULL; 180 struct file *flp = NULL;
186 mm_segment_t oldfs;
187 struct timeval tv = {0}; 181 struct timeval tv = {0};
188 182
189 flp = open_firmware_file(Adapter, path); 183 flp = open_firmware_file(Adapter, path);
190 if (!flp) { 184 if (!flp) {
191 errorno = -ENOENT;
192 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Unable to Open %s\n", path); 185 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Unable to Open %s\n", path);
193 goto exit_download; 186 return -ENOENT;
194 } 187 }
195 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Opened file is = %s and length =0x%lx to be downloaded at =0x%x", path, (unsigned long)flp->f_dentry->d_inode->i_size, loc); 188 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Opened file is = %s and length =0x%lx to be downloaded at =0x%x", path, (unsigned long)flp->f_dentry->d_inode->i_size, loc);
196 do_gettimeofday(&tv); 189 do_gettimeofday(&tv);
@@ -201,10 +194,7 @@ static int BcmFileDownload(PMINI_ADAPTER Adapter, const char *path, unsigned int
201 errorno = -EIO; 194 errorno = -EIO;
202 goto exit_download; 195 goto exit_download;
203 } 196 }
204 oldfs = get_fs();
205 set_fs(get_ds());
206 vfs_llseek(flp, 0, 0); 197 vfs_llseek(flp, 0, 0);
207 set_fs(oldfs);
208 if (Adapter->bcm_file_readback_from_chip(Adapter->pvInterfaceAdapter, flp, loc)) { 198 if (Adapter->bcm_file_readback_from_chip(Adapter->pvInterfaceAdapter, flp, loc)) {
209 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to read back firmware!"); 199 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to read back firmware!");
210 errorno = -EIO; 200 errorno = -EIO;
@@ -212,12 +202,7 @@ static int BcmFileDownload(PMINI_ADAPTER Adapter, const char *path, unsigned int
212 } 202 }
213 203
214exit_download: 204exit_download:
215 oldfs = get_fs(); 205 filp_close(flp, NULL);
216 set_fs(get_ds());
217 if (flp && !(IS_ERR(flp)))
218 filp_close(flp, current->files);
219 set_fs(oldfs);
220
221 return errorno; 206 return errorno;
222} 207}
223 208
@@ -1080,10 +1065,8 @@ OUT:
1080static int bcm_parse_target_params(PMINI_ADAPTER Adapter) 1065static int bcm_parse_target_params(PMINI_ADAPTER Adapter)
1081{ 1066{
1082 struct file *flp = NULL; 1067 struct file *flp = NULL;
1083 mm_segment_t oldfs = {0};
1084 char *buff; 1068 char *buff;
1085 int len = 0; 1069 int len = 0;
1086 loff_t pos = 0;
1087 1070
1088 buff = kmalloc(BUFFER_1K, GFP_KERNEL); 1071 buff = kmalloc(BUFFER_1K, GFP_KERNEL);
1089 if (!buff) 1072 if (!buff)
@@ -1103,20 +1086,16 @@ static int bcm_parse_target_params(PMINI_ADAPTER Adapter)
1103 Adapter->pstargetparams = NULL; 1086 Adapter->pstargetparams = NULL;
1104 return -ENOENT; 1087 return -ENOENT;
1105 } 1088 }
1106 oldfs = get_fs(); 1089 len = kernel_read(flp, 0, buff, BUFFER_1K);
1107 set_fs(get_ds()); 1090 filp_close(flp, NULL);
1108 len = vfs_read(flp, (void __user __force *)buff, BUFFER_1K, &pos);
1109 set_fs(oldfs);
1110 1091
1111 if (len != sizeof(STARGETPARAMS)) { 1092 if (len != sizeof(STARGETPARAMS)) {
1112 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Mismatch in Target Param Structure!\n"); 1093 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Mismatch in Target Param Structure!\n");
1113 kfree(buff); 1094 kfree(buff);
1114 kfree(Adapter->pstargetparams); 1095 kfree(Adapter->pstargetparams);
1115 Adapter->pstargetparams = NULL; 1096 Adapter->pstargetparams = NULL;
1116 filp_close(flp, current->files);
1117 return -ENOENT; 1097 return -ENOENT;
1118 } 1098 }
1119 filp_close(flp, current->files);
1120 1099
1121 /* Check for autolink in config params */ 1100 /* Check for autolink in config params */
1122 /* 1101 /*