[PATCH 3/3] staging: brcm80211: improved checks on incompatible firmware

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The return status of wl_ucode_init_buf() is now being used. Also a bug in
firmware validation, which could lead to incompatible firmware not being
rejected by the driver, has been fixed.

Signed-off-by: Roland Vossen <rvossen@xxxxxxxxxxxx>
Reviewed-by: Arend van Spriel <arend@xxxxxxxxxxxx>
---
 drivers/staging/brcm80211/brcmsmac/wl_mac80211.c   |    4 +-
 .../staging/brcm80211/brcmsmac/wl_ucode_loader.c   |   55 +++++++++++---------
 2 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c b/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c
index a52cbf7..ca955d6 100644
--- a/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c
+++ b/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c
@@ -1868,8 +1868,8 @@ int wl_check_firmwares(struct wl_info *wl)
 		} else {
 			/* check if ucode section overruns firmware image */
 			ucode_hdr = (struct wl_fw_hdr *)fw_hdr->data;
-			for (entry = 0; entry < wl->fw.hdr_num_entries[i] && rc;
-			     entry++, ucode_hdr++) {
+			for (entry = 0; entry < wl->fw.hdr_num_entries[i] &&
+			     !rc; entry++, ucode_hdr++) {
 				if (ucode_hdr->offset + ucode_hdr->len >
 				    fw->size) {
 					WL_ERROR("%s: conflicting bin/hdr\n",
diff --git a/drivers/staging/brcm80211/brcmsmac/wl_ucode_loader.c b/drivers/staging/brcm80211/brcmsmac/wl_ucode_loader.c
index 23e10f3..eb0f18a 100644
--- a/drivers/staging/brcm80211/brcmsmac/wl_ucode_loader.c
+++ b/drivers/staging/brcm80211/brcmsmac/wl_ucode_loader.c
@@ -43,30 +43,37 @@ int wl_ucode_data_init(struct wl_info *wl)
 	rc = wl_check_firmwares(wl);
 	if (rc < 0)
 		return rc;
-	wl_ucode_init_buf(wl, (void **)&d11lcn0bsinitvals24,
-			  D11LCN0BSINITVALS24);
-	wl_ucode_init_buf(wl, (void **)&d11lcn0initvals24, D11LCN0INITVALS24);
-	wl_ucode_init_buf(wl, (void **)&d11lcn1bsinitvals24,
-			  D11LCN1BSINITVALS24);
-	wl_ucode_init_buf(wl, (void **)&d11lcn1initvals24, D11LCN1INITVALS24);
-	wl_ucode_init_buf(wl, (void **)&d11lcn2bsinitvals24,
-			  D11LCN2BSINITVALS24);
-	wl_ucode_init_buf(wl, (void **)&d11lcn2initvals24, D11LCN2INITVALS24);
-	wl_ucode_init_buf(wl, (void **)&d11n0absinitvals16, D11N0ABSINITVALS16);
-	wl_ucode_init_buf(wl, (void **)&d11n0bsinitvals16, D11N0BSINITVALS16);
-	wl_ucode_init_buf(wl, (void **)&d11n0initvals16, D11N0INITVALS16);
-	wl_ucode_init_buf(wl, (void **)&bcm43xx_16_mimo,
-			  D11UCODE_OVERSIGHT16_MIMO);
-	wl_ucode_init_uint(wl, &bcm43xx_16_mimosz, D11UCODE_OVERSIGHT16_MIMOSZ);
-	wl_ucode_init_buf(wl, (void **)&bcm43xx_24_lcn,
-			  D11UCODE_OVERSIGHT24_LCN);
-	wl_ucode_init_uint(wl, &bcm43xx_24_lcnsz, D11UCODE_OVERSIGHT24_LCNSZ);
-	wl_ucode_init_buf(wl, (void **)&bcm43xx_bommajor,
-			  D11UCODE_OVERSIGHT_BOMMAJOR);
-	wl_ucode_init_buf(wl, (void **)&bcm43xx_bomminor,
-			  D11UCODE_OVERSIGHT_BOMMINOR);
-
-	return 0;
+	rc = rc || wl_ucode_init_buf(wl, (void **)&d11lcn0bsinitvals24,
+				     D11LCN0BSINITVALS24);
+	rc = rc || wl_ucode_init_buf(wl, (void **)&d11lcn0initvals24,
+				     D11LCN0INITVALS24);
+	rc = rc || wl_ucode_init_buf(wl, (void **)&d11lcn1bsinitvals24,
+				     D11LCN1BSINITVALS24);
+	rc = rc || wl_ucode_init_buf(wl, (void **)&d11lcn1initvals24,
+				     D11LCN1INITVALS24);
+	rc = rc || wl_ucode_init_buf(wl, (void **)&d11lcn2bsinitvals24,
+				     D11LCN2BSINITVALS24);
+	rc = rc || wl_ucode_init_buf(wl, (void **)&d11lcn2initvals24,
+				     D11LCN2INITVALS24);
+	rc = rc || wl_ucode_init_buf(wl, (void **)&d11n0absinitvals16,
+				     D11N0ABSINITVALS16);
+	rc = rc || wl_ucode_init_buf(wl, (void **)&d11n0bsinitvals16,
+				     D11N0BSINITVALS16);
+	rc = rc || wl_ucode_init_buf(wl, (void **)&d11n0initvals16,
+				     D11N0INITVALS16);
+	rc = rc || wl_ucode_init_buf(wl, (void **)&bcm43xx_16_mimo,
+				     D11UCODE_OVERSIGHT16_MIMO);
+	rc = rc || wl_ucode_init_uint(wl, &bcm43xx_16_mimosz,
+				      D11UCODE_OVERSIGHT16_MIMOSZ);
+	rc = rc || wl_ucode_init_buf(wl, (void **)&bcm43xx_24_lcn,
+				     D11UCODE_OVERSIGHT24_LCN);
+	rc = rc || wl_ucode_init_uint(wl, &bcm43xx_24_lcnsz,
+				      D11UCODE_OVERSIGHT24_LCNSZ);
+	rc = rc || wl_ucode_init_buf(wl, (void **)&bcm43xx_bommajor,
+				     D11UCODE_OVERSIGHT_BOMMAJOR);
+	rc = rc || wl_ucode_init_buf(wl, (void **)&bcm43xx_bomminor,
+				     D11UCODE_OVERSIGHT_BOMMINOR);
+	return rc;
 }
 
 void wl_ucode_data_free(void)
-- 
1.7.1


_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux