]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.7.4/firmware-make-sure-the-fw-file-size-is-not-0.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.7.4 / firmware-make-sure-the-fw-file-size-is-not-0.patch
1 From 4adf07fba3bd64472921a01aae0e116f9f948b77 Mon Sep 17 00:00:00 2001
2 From: Luciano Coelho <coelho@ti.com>
3 Date: Tue, 15 Jan 2013 10:43:43 +0200
4 Subject: firmware: make sure the fw file size is not 0
5
6 From: Luciano Coelho <coelho@ti.com>
7
8 commit 4adf07fba3bd64472921a01aae0e116f9f948b77 upstream.
9
10 If the requested firmware file size is 0 bytes in the filesytem, we
11 will try to vmalloc(0), which causes a warning:
12
13 vmalloc: allocation failure: 0 bytes
14 kworker/1:1: page allocation failure: order:0, mode:0xd2
15 __vmalloc_node_range+0x164/0x208
16 __vmalloc_node+0x4c/0x58
17 vmalloc+0x38/0x44
18 _request_firmware_load+0x220/0x6b0
19 request_firmware+0x64/0xc8
20 wl18xx_setup+0xb4/0x570 [wl18xx]
21 wlcore_nvs_cb+0x64/0x9f8 [wlcore]
22 request_firmware_work_func+0x94/0x100
23 process_one_work+0x1d0/0x750
24 worker_thread+0x184/0x4ac
25 kthread+0xb4/0xc0
26
27 To fix this, check whether the file size is less than or equal to zero
28 in fw_read_file_contents().
29
30 Signed-off-by: Luciano Coelho <coelho@ti.com>
31 Acked-by: Ming Lei <ming.lei@canonical.com>
32 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
33 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
34
35 ---
36 drivers/base/firmware_class.c | 2 +-
37 1 file changed, 1 insertion(+), 1 deletion(-)
38
39 --- a/drivers/base/firmware_class.c
40 +++ b/drivers/base/firmware_class.c
41 @@ -295,7 +295,7 @@ static bool fw_read_file_contents(struct
42 char *buf;
43
44 size = fw_file_size(file);
45 - if (size < 0)
46 + if (size <= 0)
47 return false;
48 buf = vmalloc(size);
49 if (!buf)