diff mbox

mwifiex: pcie: tighten a check in mwifiex_pcie_process_event_ready()

Message ID 20180405111719.GB4218@mwanda (mailing list archive)
State Accepted
Commit 01eca2842874b9a85b7cd1e1b0e5b34a5d53a21f
Delegated to: Kalle Valo
Headers show

Commit Message

Dan Carpenter April 5, 2018, 11:17 a.m. UTC
If "evt_len" is 1 then we try to memcpy() negative 3 bytes and it would
cause memory corruption.

Fixes: d930faee141b ("mwifiex: add support for Marvell pcie8766 chipset")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Kalle Valo April 25, 2018, 8:21 a.m. UTC | #1
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> If "evt_len" is 1 then we try to memcpy() negative 3 bytes and it would
> cause memory corruption.
> 
> Fixes: d930faee141b ("mwifiex: add support for Marvell pcie8766 chipset")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
> index 97a6199692ab..7538543d46fa 100644
> --- a/drivers/net/wireless/marvell/mwifiex/pcie.c
> +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
> @@ -1881,7 +1881,8 @@ static int mwifiex_pcie_process_event_ready(struct mwifiex_adapter *adapter)
>  		mwifiex_dbg(adapter, EVENT,
>  			    "info: Event length: %d\n", evt_len);
>  
> -		if ((evt_len > 0) && (evt_len  < MAX_EVENT_SIZE))
> +		if (evt_len > MWIFIEX_EVENT_HEADER_LEN &&
> +		    evt_len < MAX_EVENT_SIZE)
>  			memcpy(adapter->event_body, skb_cmd->data +
>  			       MWIFIEX_EVENT_HEADER_LEN, evt_len -
>  			       MWIFIEX_EVENT_HEADER_LEN);

Patch applied to wireless-drivers-next.git, thanks.

01eca2842874 mwifiex: pcie: tighten a check in mwifiex_pcie_process_event_ready()
diff mbox

Patch

diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
index 97a6199692ab..7538543d46fa 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -1881,7 +1881,8 @@  static int mwifiex_pcie_process_event_ready(struct mwifiex_adapter *adapter)
 		mwifiex_dbg(adapter, EVENT,
 			    "info: Event length: %d\n", evt_len);
 
-		if ((evt_len > 0) && (evt_len  < MAX_EVENT_SIZE))
+		if (evt_len > MWIFIEX_EVENT_HEADER_LEN &&
+		    evt_len < MAX_EVENT_SIZE)
 			memcpy(adapter->event_body, skb_cmd->data +
 			       MWIFIEX_EVENT_HEADER_LEN, evt_len -
 			       MWIFIEX_EVENT_HEADER_LEN);