diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-04 12:19:02 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-04 12:19:02 -0400 |
| commit | ce57e981f2b996aaca2031003b3f866368307766 (patch) | |
| tree | 7ab6b29e6b0013519f3418bbaf8f661e064861ba | |
| parent | e1cc485262846dcad931bf85ee655cbbb815bfe6 (diff) | |
firmware: use 'kernel_read()' to read firmware into kernel buffer
Fengguang correctly points out that the firmware reading should not use
vfs_read(), since the buffer is in kernel space.
The vfs_read() just happened to work for kernel threads, but sparse
warns about the incorrect address spaces, and it's definitely incorrect
and could fail for other users of the firmware loading.
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
| -rw-r--r-- | drivers/base/firmware_class.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index e85763de928f..81541452887b 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
| @@ -58,7 +58,6 @@ static noinline long fw_file_size(struct file *file) | |||
| 58 | 58 | ||
| 59 | static bool fw_read_file_contents(struct file *file, struct firmware *fw) | 59 | static bool fw_read_file_contents(struct file *file, struct firmware *fw) |
| 60 | { | 60 | { |
| 61 | loff_t pos; | ||
| 62 | long size; | 61 | long size; |
| 63 | char *buf; | 62 | char *buf; |
| 64 | 63 | ||
| @@ -68,8 +67,7 @@ static bool fw_read_file_contents(struct file *file, struct firmware *fw) | |||
| 68 | buf = vmalloc(size); | 67 | buf = vmalloc(size); |
| 69 | if (!buf) | 68 | if (!buf) |
| 70 | return false; | 69 | return false; |
| 71 | pos = 0; | 70 | if (kernel_read(file, 0, buf, size) != size) { |
| 72 | if (vfs_read(file, buf, size, &pos) != size) { | ||
| 73 | vfree(buf); | 71 | vfree(buf); |
| 74 | return false; | 72 | return false; |
| 75 | } | 73 | } |
