diff options
-rw-r--r-- | drivers/base/firmware_class.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 46ea5f4c3bb5..304691c5e2bc 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -284,26 +284,15 @@ static const char * const fw_path[] = { | |||
284 | module_param_string(path, fw_path_para, sizeof(fw_path_para), 0644); | 284 | module_param_string(path, fw_path_para, sizeof(fw_path_para), 0644); |
285 | MODULE_PARM_DESC(path, "customized firmware image search path with a higher priority than default path"); | 285 | MODULE_PARM_DESC(path, "customized firmware image search path with a higher priority than default path"); |
286 | 286 | ||
287 | /* Don't inline this: 'struct kstat' is biggish */ | ||
288 | static noinline_for_stack int fw_file_size(struct file *file) | ||
289 | { | ||
290 | struct kstat st; | ||
291 | if (vfs_getattr(&file->f_path, &st)) | ||
292 | return -1; | ||
293 | if (!S_ISREG(st.mode)) | ||
294 | return -1; | ||
295 | if (st.size != (int)st.size) | ||
296 | return -1; | ||
297 | return st.size; | ||
298 | } | ||
299 | |||
300 | static int fw_read_file_contents(struct file *file, struct firmware_buf *fw_buf) | 287 | static int fw_read_file_contents(struct file *file, struct firmware_buf *fw_buf) |
301 | { | 288 | { |
302 | int size; | 289 | int size; |
303 | char *buf; | 290 | char *buf; |
304 | int rc; | 291 | int rc; |
305 | 292 | ||
306 | size = fw_file_size(file); | 293 | if (!S_ISREG(file_inode(file)->i_mode)) |
294 | return -EINVAL; | ||
295 | size = i_size_read(file_inode(file)); | ||
307 | if (size <= 0) | 296 | if (size <= 0) |
308 | return -EINVAL; | 297 | return -EINVAL; |
309 | buf = vmalloc(size); | 298 | buf = vmalloc(size); |