OSDN Git Service

ucc_geth: Fix NULL pointer dereference in uec_get_ethtool_stats()
[armadillo-ux/linux-2.6-armadillo.git] / drivers / net / ucc_geth_ethtool.c
index 6fcb500..304128f 100644 (file)
@@ -7,7 +7,7 @@
  *
  * Limitation:
  * Can only get/set setttings of the first queue.
- * Need to re-open the interface manually after changing some paramters.
+ * Need to re-open the interface manually after changing some parameters.
  *
  * This program is free software; you can redistribute  it and/or modify it
  * under  the terms of  the GNU General  Public License as published by the
@@ -319,9 +319,13 @@ static void uec_get_ethtool_stats(struct net_device *netdev,
        int i, j = 0;
 
        if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_HARDWARE) {
-               base = (u32 __iomem *)&ugeth->ug_regs->tx64;
+               if (ugeth->ug_regs)
+                       base = (u32 __iomem *)&ugeth->ug_regs->tx64;
+               else
+                       base = NULL;
+
                for (i = 0; i < UEC_HW_STATS_LEN; i++)
-                       data[j++] = in_be32(&base[i]);
+                       data[j++] = base ? in_be32(&base[i]) : 0;
        }
        if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX) {
                base = (u32 __iomem *)ugeth->p_tx_fw_statistics_pram;