iwlwifi: don't crash on firmware file missing info
authorJohannes Berg <johannes.berg@intel.com>
Mon, 3 May 2010 08:17:57 +0000 (01:17 -0700)
committerReinette Chatre <reinette.chatre@intel.com>
Thu, 13 May 2010 17:43:06 +0000 (10:43 -0700)
If a firmware file misses one of the required
instruction or data pieces, the driver currently
crashes. Let it gracefully refuse that firmware
file instead.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
drivers/net/wireless/iwlwifi/iwl-helpers.h

index 3ff6b9d..6984639 100644 (file)
@@ -92,6 +92,11 @@ static inline void iwl_free_fw_desc(struct pci_dev *pci_dev,
 static inline int iwl_alloc_fw_desc(struct pci_dev *pci_dev,
                                    struct fw_desc *desc)
 {
+       if (!desc->len) {
+               desc->v_addr = NULL;
+               return -EINVAL;
+       }
+
        desc->v_addr = dma_alloc_coherent(&pci_dev->dev, desc->len,
                                          &desc->p_addr, GFP_KERNEL);
        return (desc->v_addr != NULL) ? 0 : -ENOMEM;