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 3ff6b9d25a10665397c5b87285207d5591293993..69846395763b5805b4554929ff3ae20668dd71a6 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;