--- initial
+++ final
@@ -1,130 +1,129 @@
 int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len) {
   struct p54_common *priv = dev->priv;
   struct eeprom_pda_wrap *wrap;
   struct pda_entry *entry;
   unsigned int data_len, entry_len;
   void *tmp;
   int err;
   u8 *end = (u8 *)eeprom + len;
   u16 synth = 0;
   wrap = (struct eeprom_pda_wrap *)eeprom;
   entry = (void *)wrap->data + le16_to_cpu(wrap->len);
   /* verify that at least the entry length/code fits */
   while ((u8 *)entry <= end - sizeof(*entry)) {
     entry_len = le16_to_cpu(entry->len);
     data_len = ((entry_len - 1) << 1);
     /* abort if entry exceeds whole structure */
     if ((u8 *)entry + sizeof(*entry) + data_len > end) break;
     switch (le16_to_cpu(entry->code)) {
     case PDR_MAC_ADDRESS:
       if (data_len != ETH_ALEN) break;
       SET_IEEE80211_PERM_ADDR(dev, entry->data);
       break;
     case PDR_PRISM_PA_CAL_OUTPUT_POWER_LIMITS:
       if (priv->output_limit) break;
       err = p54_convert_output_limits(dev, entry->data, data_len);
       if (err) goto err;
       break;
     case PDR_PRISM_PA_CAL_CURVE_DATA: {
       struct pda_pa_curve_data *curve_data = (struct pda_pa_curve_data *)entry->data;
       if (data_len < sizeof(*curve_data)) {
         err = -EINVAL;
         goto err;
       }
       switch (curve_data->cal_method_rev) {
       case 0: err = p54_convert_rev0(dev, curve_data); break;
       case 1: err = p54_convert_rev1(dev, curve_data); break;
       default:
         printk(KERN_ERR "%s: unknown curve data "
                         "revision %d\n",
                wiphy_name(dev->wiphy), curve_data->cal_method_rev);
         err = -ENODEV;
         break;
       }
       if (err) goto err;
     } break;
     case PDR_PRISM_ZIF_TX_IQ_CALIBRATION:
-      priv->iq_autocal = kmalloc(data_len, GFP_KERNEL);
+      priv->iq_autocal = kmemdup(entry->data, data_len, GFP_KERNEL);
       if (!priv->iq_autocal) {
         err = -ENOMEM;
         goto err;
       }
-      memcpy(priv->iq_autocal, entry->data, data_len);
       priv->iq_autocal_len = data_len / sizeof(struct pda_iq_autocal_entry);
       break;
     case PDR_DEFAULT_COUNTRY: p54_parse_default_country(dev, entry->data, data_len); break;
     case PDR_INTERFACE_LIST:
       tmp = entry->data;
       while ((u8 *)tmp < entry->data + data_len) {
         struct exp_if *exp_if = tmp;
         if (exp_if->if_id == cpu_to_le16(IF_ID_ISL39000)) synth = le16_to_cpu(exp_if->variant);
         tmp += sizeof(*exp_if);
       }
       break;
     case PDR_HARDWARE_PLATFORM_COMPONENT_ID:
       if (data_len < 2) break;
       priv->version = *(u8 *)(entry->data + 1);
       break;
     case PDR_RSSI_LINEAR_APPROXIMATION:
     case PDR_RSSI_LINEAR_APPROXIMATION_DUAL_BAND:
     case PDR_RSSI_LINEAR_APPROXIMATION_EXTENDED: p54_parse_rssical(dev, entry->data, data_len, le16_to_cpu(entry->code)); break;
     case PDR_RSSI_LINEAR_APPROXIMATION_CUSTOM: {
       __le16 *src = (void *)entry->data;
       s16 *dst = (void *)&priv->rssical_db;
       int i;
       if (data_len != sizeof(priv->rssical_db)) {
         err = -EINVAL;
         goto err;
       }
       for (i = 0; i < sizeof(priv->rssical_db) / sizeof(*src); i++)
         *(dst++) = (s16)le16_to_cpu(*(src++));
     } break;
     case PDR_PRISM_PA_CAL_OUTPUT_POWER_LIMITS_CUSTOM: {
       struct pda_custom_wrapper *pda = (void *)entry->data;
       if (priv->output_limit || data_len < sizeof(*pda)) break;
       priv->output_limit = p54_convert_db(pda, data_len);
     } break;
     case PDR_PRISM_PA_CAL_CURVE_DATA_CUSTOM: {
       struct pda_custom_wrapper *pda = (void *)entry->data;
       if (priv->curve_data || data_len < sizeof(*pda)) break;
       priv->curve_data = p54_convert_db(pda, data_len);
     } break;
     case PDR_END:
       /* make it overrun */
       entry_len = len;
       break;
     default: break;
     }
     entry = (void *)entry + (entry_len + 1) * 2;
   }
   if (!synth || !priv->iq_autocal || !priv->output_limit || !priv->curve_data) {
     printk(KERN_ERR "%s: not all required entries found in eeprom!\n", wiphy_name(dev->wiphy));
     err = -EINVAL;
     goto err;
   }
   err = p54_generate_channel_lists(dev);
   if (err) goto err;
   priv->rxhw = synth & PDR_SYNTH_FRONTEND_MASK;
   if (priv->rxhw == PDR_SYNTH_FRONTEND_XBOW) p54_init_xbow_synth(priv);
   if (!(synth & PDR_SYNTH_24_GHZ_DISABLED)) dev->wiphy->bands[IEEE80211_BAND_2GHZ] = priv->band_table[IEEE80211_BAND_2GHZ];
   if (!(synth & PDR_SYNTH_5_GHZ_DISABLED)) dev->wiphy->bands[IEEE80211_BAND_5GHZ] = priv->band_table[IEEE80211_BAND_5GHZ];
   if ((synth & PDR_SYNTH_RX_DIV_MASK) == PDR_SYNTH_RX_DIV_SUPPORTED) priv->rx_diversity_mask = 3;
   if ((synth & PDR_SYNTH_TX_DIV_MASK) == PDR_SYNTH_TX_DIV_SUPPORTED) priv->tx_diversity_mask = 3;
   if (!is_valid_ether_addr(dev->wiphy->perm_addr)) {
     u8 perm_addr[ETH_ALEN];
     printk(KERN_WARNING "%s: Invalid hwaddr! Using randomly generated MAC addr\n", wiphy_name(dev->wiphy));
     random_ether_addr(perm_addr);
     SET_IEEE80211_PERM_ADDR(dev, perm_addr);
   }
   printk(KERN_INFO "%s: hwaddr %pM, MAC:isl38%02x RF:%s\n", wiphy_name(dev->wiphy), dev->wiphy->perm_addr, priv->version, p54_rf_chips[priv->rxhw]);
   return 0;
 err:
   kfree(priv->iq_autocal);
   kfree(priv->output_limit);
   kfree(priv->curve_data);
   priv->iq_autocal = NULL;
   priv->output_limit = NULL;
   priv->curve_data = NULL;
   printk(KERN_ERR "%s: eeprom parse failed!\n", wiphy_name(dev->wiphy));
   return err;
 }<sep>@@
expression from,to,size,flag;
statement S;
@@
    
-  to = \(kmalloc\|kzalloc\)(size,flag);
+  to = kmemdup(from,size,flag);
       if (to==NULL || ...) S
-  memcpy(to, from, size);