Commit 4adf07fb authored by Luciano Coelho's avatar Luciano Coelho Committed by Linus Torvalds
Browse files

firmware: make sure the fw file size is not 0

If the requested firmware file size is 0 bytes in the filesytem, we
will try to vmalloc(0), which causes a warning:

  vmalloc: allocation failure: 0 bytes
  kworker/1:1: page allocation failure: order:0, mode:0xd2
    wl18xx_setup+0xb4/0x570 [wl18xx]
    wlcore_nvs_cb+0x64/0x9f8 [wlcore]

To fix this, check whether the file size is less than or equal to zero
in fw_read_file_contents().

Cc: stable <> [3.7]
Signed-off-by: default avatarLuciano Coelho <>
Acked-by: default avatarMing Lei <>
Signed-off-by: default avatarLinus Torvalds <>
parent 774a1221
......@@ -305,7 +305,7 @@ static bool fw_read_file_contents(struct file *file, struct firmware_buf *fw_buf
char *buf;
size = fw_file_size(file);
if (size < 0)
if (size <= 0)
return false;
buf = vmalloc(size);
if (!buf)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment