mwifiex: prevent corruption instead of just warning
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 8 Nov 2011 03:31:47 +0000 (19:31 -0800)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 9 Nov 2011 21:14:13 +0000 (16:14 -0500)
Probably we never hit this condition, but in case we do, we may as
well put a return here instead of just printing a warning message and
then corrupting memory.  The caller doesn't check the return code.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/mwifiex/pcie.c

index d12d440554892fbb56a1cdb34a7beee489755093..a2f32008f9a80810355c8c4cc145ada8199d9516 100644 (file)
@@ -1228,9 +1228,12 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter,
        if (!skb)
                return 0;
 
-       if (rdptr >= MWIFIEX_MAX_EVT_BD)
+       if (rdptr >= MWIFIEX_MAX_EVT_BD) {
                dev_err(adapter->dev, "event_complete: Invalid rdptr 0x%x\n",
                                        rdptr);
+               ret = -EINVAL;
+               goto done;
+       }
 
        /* Read the event ring write pointer set by firmware */
        if (mwifiex_read_reg(adapter, REG_EVTBD_WRPTR, &wrptr)) {