提交 ed317788 编写于 作者: J Juuso Oikarinen 提交者: John W. Linville

wl1271: Correct memory handling for FW boot

Several memory allocation related failure cases were not properly
handled by the driver - the result was that in low memory conditions
booting of a corrupted FW could be attempted - and user space would not
get proper failure code.
Signed-off-by: NJuuso Oikarinen <juuso.oikarinen@nokia.com>
Reviewed-by: NLuciano Coelho <luciano.coelho@nokia.com>
Signed-off-by: NLuciano Coelho <luciano.coelho@nokia.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 a163acce
...@@ -134,7 +134,7 @@ static int wl1271_boot_upload_firmware_chunk(struct wl1271 *wl, void *buf, ...@@ -134,7 +134,7 @@ static int wl1271_boot_upload_firmware_chunk(struct wl1271 *wl, void *buf,
} }
chunk = kmalloc(CHUNK_SIZE, GFP_KERNEL); chunk = kmalloc(CHUNK_SIZE, GFP_KERNEL);
if (!buf) { if (!chunk) {
wl1271_error("allocation for firmware upload chunk failed"); wl1271_error("allocation for firmware upload chunk failed");
return -ENOMEM; return -ENOMEM;
} }
...@@ -184,6 +184,7 @@ static int wl1271_boot_upload_firmware_chunk(struct wl1271 *wl, void *buf, ...@@ -184,6 +184,7 @@ static int wl1271_boot_upload_firmware_chunk(struct wl1271 *wl, void *buf,
static int wl1271_boot_upload_firmware(struct wl1271 *wl) static int wl1271_boot_upload_firmware(struct wl1271 *wl)
{ {
u32 chunks, addr, len; u32 chunks, addr, len;
int ret = 0;
u8 *fw; u8 *fw;
fw = wl->fw; fw = wl->fw;
...@@ -204,11 +205,13 @@ static int wl1271_boot_upload_firmware(struct wl1271 *wl) ...@@ -204,11 +205,13 @@ static int wl1271_boot_upload_firmware(struct wl1271 *wl)
} }
wl1271_debug(DEBUG_BOOT, "chunk %d addr 0x%x len %u", wl1271_debug(DEBUG_BOOT, "chunk %d addr 0x%x len %u",
chunks, addr, len); chunks, addr, len);
wl1271_boot_upload_firmware_chunk(wl, fw, len, addr); ret = wl1271_boot_upload_firmware_chunk(wl, fw, len, addr);
if (ret != 0)
break;
fw += len; fw += len;
} }
return 0; return ret;
} }
static int wl1271_boot_upload_nvs(struct wl1271 *wl) static int wl1271_boot_upload_nvs(struct wl1271 *wl)
...@@ -284,6 +287,8 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl) ...@@ -284,6 +287,8 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
/* Copy the NVS tables to a new block to ensure alignment */ /* Copy the NVS tables to a new block to ensure alignment */
nvs_aligned = kmemdup(nvs_ptr, nvs_len, GFP_KERNEL); nvs_aligned = kmemdup(nvs_ptr, nvs_len, GFP_KERNEL);
if (!nvs_aligned)
return -ENOMEM;
/* And finally we upload the NVS tables */ /* And finally we upload the NVS tables */
/* FIXME: In wl1271, we upload everything at once. /* FIXME: In wl1271, we upload everything at once.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册