ath10k: fix dma_mapping_error() handling
authorMichal Kazior <michal.kazior@tieto.com>
Wed, 19 Aug 2015 11:10:43 +0000 (13:10 +0200)
committerKalle Valo <kvalo@qca.qualcomm.com>
Wed, 26 Aug 2015 08:04:44 +0000 (11:04 +0300)
The function returns 1 when DMA mapping fails. The
driver would return bogus values and could
possibly confuse itself if DMA failed.

Fixes: 767d34fc67af ("ath10k: remove DMA mapping wrappers")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/ath10k/htc.c
drivers/net/wireless/ath/ath10k/htt_tx.c
drivers/net/wireless/ath/ath10k/pci.c
drivers/net/wireless/ath/ath10k/wmi.c

index 85bfa2acb801b8945a7d825bfbc91f126d82c655..32d9ff1b19dcdf2d6d2609e9f95844fb5d144e8d 100644 (file)
@@ -145,8 +145,10 @@ int ath10k_htc_send(struct ath10k_htc *htc,
        skb_cb->eid = eid;
        skb_cb->paddr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
        ret = dma_mapping_error(dev, skb_cb->paddr);
-       if (ret)
+       if (ret) {
+               ret = -EIO;
                goto err_credits;
+       }
 
        sg_item.transfer_id = ep->eid;
        sg_item.transfer_context = skb;
index 704bb5e071938b7e3f56b9b42fa8304c3dbe2fed..43aa5e2d1b87d2751be83d52fdbc3bc6c89b7b17 100644 (file)
@@ -442,8 +442,10 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
        skb_cb->paddr = dma_map_single(dev, msdu->data, msdu->len,
                                       DMA_TO_DEVICE);
        res = dma_mapping_error(dev, skb_cb->paddr);
-       if (res)
+       if (res) {
+               res = -EIO;
                goto err_free_txdesc;
+       }
 
        skb_put(txdesc, len);
        cmd = (struct htt_cmd *)txdesc->data;
@@ -533,8 +535,10 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
        skb_cb->paddr = dma_map_single(dev, msdu->data, msdu->len,
                                       DMA_TO_DEVICE);
        res = dma_mapping_error(dev, skb_cb->paddr);
-       if (res)
+       if (res) {
+               res = -EIO;
                goto err_free_txbuf;
+       }
 
        switch (skb_cb->txmode) {
        case ATH10K_HW_TXRX_RAW:
index f00b251ec9ce92f15275ec51c3ff292da3dd423d..826220f795c7082e1d64588e6492e8afd799e374 100644 (file)
@@ -1667,8 +1667,10 @@ static int ath10k_pci_hif_exchange_bmi_msg(struct ath10k *ar,
 
        req_paddr = dma_map_single(ar->dev, treq, req_len, DMA_TO_DEVICE);
        ret = dma_mapping_error(ar->dev, req_paddr);
-       if (ret)
+       if (ret) {
+               ret = -EIO;
                goto err_dma;
+       }
 
        if (resp && resp_len) {
                tresp = kzalloc(*resp_len, GFP_KERNEL);
@@ -1680,8 +1682,10 @@ static int ath10k_pci_hif_exchange_bmi_msg(struct ath10k *ar,
                resp_paddr = dma_map_single(ar->dev, tresp, *resp_len,
                                            DMA_FROM_DEVICE);
                ret = dma_mapping_error(ar->dev, resp_paddr);
-               if (ret)
+               if (ret) {
+                       ret = EIO;
                        goto err_req;
+               }
 
                xfer.wait_for_resp = true;
                xfer.resp_len = 0;
index 42c0aba04fb2409bc192af5f292a1d85f2607ec2..6ac016dc28f86f5a3d172bc1bb652c7647c6ac33 100644 (file)
@@ -3238,6 +3238,7 @@ void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
                                ath10k_warn(ar, "failed to map beacon: %d\n",
                                            ret);
                                dev_kfree_skb_any(bcn);
+                               ret = -EIO;
                                goto skip;
                        }