diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2013-12-28 10:53:59 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-01-08 23:29:19 -0500 |
commit | 08da2012e0bb0f3f1422cce3f76c36a90da366b5 (patch) | |
tree | 62ebb93c62391db44bc3f29db6c34667df6fddbc | |
parent | 174be70b638ceb1038f466b5ca014f6b1d9c8a59 (diff) |
firmware_class: Fix the file size check
We expect to read firmware blobs with a single call to kernel_read(),
which returns int. Therefore the size must be within the range of
int, not long.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/base/firmware_class.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 54592e66551f..8a97ddfa6122 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -280,21 +280,21 @@ module_param_string(path, fw_path_para, sizeof(fw_path_para), 0644); | |||
280 | MODULE_PARM_DESC(path, "customized firmware image search path with a higher priority than default path"); | 280 | MODULE_PARM_DESC(path, "customized firmware image search path with a higher priority than default path"); |
281 | 281 | ||
282 | /* Don't inline this: 'struct kstat' is biggish */ | 282 | /* Don't inline this: 'struct kstat' is biggish */ |
283 | static noinline_for_stack long fw_file_size(struct file *file) | 283 | static noinline_for_stack int fw_file_size(struct file *file) |
284 | { | 284 | { |
285 | struct kstat st; | 285 | struct kstat st; |
286 | if (vfs_getattr(&file->f_path, &st)) | 286 | if (vfs_getattr(&file->f_path, &st)) |
287 | return -1; | 287 | return -1; |
288 | if (!S_ISREG(st.mode)) | 288 | if (!S_ISREG(st.mode)) |
289 | return -1; | 289 | return -1; |
290 | if (st.size != (long)st.size) | 290 | if (st.size != (int)st.size) |
291 | return -1; | 291 | return -1; |
292 | return st.size; | 292 | return st.size; |
293 | } | 293 | } |
294 | 294 | ||
295 | static int fw_read_file_contents(struct file *file, struct firmware_buf *fw_buf) | 295 | static int fw_read_file_contents(struct file *file, struct firmware_buf *fw_buf) |
296 | { | 296 | { |
297 | long size; | 297 | int size; |
298 | char *buf; | 298 | char *buf; |
299 | int rc; | 299 | int rc; |
300 | 300 | ||