aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/wl12xx/boot.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/net/wireless/wl12xx/boot.c b/drivers/net/wireless/wl12xx/boot.c
index 6e140bf4e236..8f9cf5a816ea 100644
--- a/drivers/net/wireless/wl12xx/boot.c
+++ b/drivers/net/wireless/wl12xx/boot.c
@@ -348,6 +348,9 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
348 nvs_ptr += 3; 348 nvs_ptr += 3;
349 349
350 for (i = 0; i < burst_len; i++) { 350 for (i = 0; i < burst_len; i++) {
351 if (nvs_ptr + 3 >= (u8 *) wl->nvs + nvs_len)
352 goto out_badnvs;
353
351 val = (nvs_ptr[0] | (nvs_ptr[1] << 8) 354 val = (nvs_ptr[0] | (nvs_ptr[1] << 8)
352 | (nvs_ptr[2] << 16) | (nvs_ptr[3] << 24)); 355 | (nvs_ptr[2] << 16) | (nvs_ptr[3] << 24));
353 356
@@ -359,6 +362,9 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
359 nvs_ptr += 4; 362 nvs_ptr += 4;
360 dest_addr += 4; 363 dest_addr += 4;
361 } 364 }
365
366 if (nvs_ptr >= (u8 *) wl->nvs + nvs_len)
367 goto out_badnvs;
362 } 368 }
363 369
364 /* 370 /*
@@ -370,6 +376,10 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
370 */ 376 */
371 nvs_ptr = (u8 *)wl->nvs + 377 nvs_ptr = (u8 *)wl->nvs +
372 ALIGN(nvs_ptr - (u8 *)wl->nvs + 7, 4); 378 ALIGN(nvs_ptr - (u8 *)wl->nvs + 7, 4);
379
380 if (nvs_ptr >= (u8 *) wl->nvs + nvs_len)
381 goto out_badnvs;
382
373 nvs_len -= nvs_ptr - (u8 *)wl->nvs; 383 nvs_len -= nvs_ptr - (u8 *)wl->nvs;
374 384
375 /* Now we must set the partition correctly */ 385 /* Now we must set the partition correctly */
@@ -385,6 +395,10 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
385 395
386 kfree(nvs_aligned); 396 kfree(nvs_aligned);
387 return 0; 397 return 0;
398
399out_badnvs:
400 wl1271_error("nvs data is malformed");
401 return -EILSEQ;
388} 402}
389 403
390static void wl1271_boot_enable_interrupts(struct wl1271 *wl) 404static void wl1271_boot_enable_interrupts(struct wl1271 *wl)