summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/net/wireless/marvell/libertas/if_usb.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/net/wireless/marvell/libertas/if_usb.c b/drivers/net/wireless/marvell/libertas/if_usb.c
index 5cc0c5cac257..74870c9bd091 100644
--- a/drivers/net/wireless/marvell/libertas/if_usb.c
+++ b/drivers/net/wireless/marvell/libertas/if_usb.c
@@ -798,10 +798,18 @@ static int check_fwfile_format(const uint8_t *data, uint32_t totlen)
exit = len = 0;
do {
- struct fwheader *fwh = (void *)data;
+ struct fwheader *fwh;
+
+ if (totlen - len < sizeof(*fwh))
+ break;
+
+ fwh = (void *)data;
bincmd = le32_to_cpu(fwh->dnldcmd);
blksize = le32_to_cpu(fwh->datalength);
+ if (blksize > totlen - len - sizeof(*fwh))
+ break;
+
switch (bincmd) {
case FW_HAS_DATA_TO_RECV:
offset = sizeof(struct fwheader) + blksize;