From 2d0f461df45b4e45bcb4008fe5cfa77c1231d2d3 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 4 Oct 2012 09:19:02 -0700 Subject: [PATCH] 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 Signed-off-by: Linus Torvalds --- drivers/base/firmware_class.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index e390fff37975..bb9e2db7c5ff 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -60,7 +60,6 @@ static noinline long fw_file_size(struct file *file) static bool fw_read_file_contents(struct file *file, struct firmware *fw) { - loff_t pos; long size; char *buf; @@ -70,8 +69,7 @@ static bool fw_read_file_contents(struct file *file, struct firmware *fw) buf = vmalloc(size); if (!buf) return false; - pos = 0; - if (vfs_read(file, buf, size, &pos) != size) { + if (kernel_read(file, 0, buf, size) != size) { vfree(buf); return false; } -- 2.20.1