Merge branch 'for-john' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac802...
[cascardo/linux.git] / drivers / net / wireless / iwlegacy / common.c
index 4c9aafb..e006ea8 100644 (file)
@@ -3160,18 +3160,23 @@ il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd)
                     idx, il->cmd_queue);
        }
 #endif
-       txq->need_update = 1;
-
-       if (il->ops->txq_update_byte_cnt_tbl)
-               /* Set up entry in queue's byte count circular buffer */
-               il->ops->txq_update_byte_cnt_tbl(il, txq, 0);
 
        phys_addr =
            pci_map_single(il->pci_dev, &out_cmd->hdr, fix_size,
                           PCI_DMA_BIDIRECTIONAL);
+       if (unlikely(pci_dma_mapping_error(il->pci_dev, phys_addr))) {
+               idx = -ENOMEM;
+               goto out;
+       }
        dma_unmap_addr_set(out_meta, mapping, phys_addr);
        dma_unmap_len_set(out_meta, len, fix_size);
 
+       txq->need_update = 1;
+
+       if (il->ops->txq_update_byte_cnt_tbl)
+               /* Set up entry in queue's byte count circular buffer */
+               il->ops->txq_update_byte_cnt_tbl(il, txq, 0);
+
        il->ops->txq_attach_buf_to_tfd(il, txq, phys_addr, fix_size, 1,
                                            U32_PAD(cmd->len));
 
@@ -3179,6 +3184,7 @@ il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd)
        q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd);
        il_txq_update_write_ptr(il, txq);
 
+out:
        spin_unlock_irqrestore(&il->hcmd_lock, flags);
        return idx;
 }