summaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
authorIoana Radulescu <ruxandra.radulescu@freescale.com>2013-08-28 15:24:34 (GMT)
committerRivera Jose-B46482 <German.Rivera@freescale.com>2013-09-10 23:22:53 (GMT)
commit25596a1c0ad9dcd6e4948fbc9246ae394750e49e (patch)
tree5f7f7c739aa0bd8e5a37dd2449cd5ce0028fa0e4 /drivers/net
parentf44a73568f3fb888753002dc7e3daedd74fd7033 (diff)
downloadlinux-fsl-qoriq-25596a1c0ad9dcd6e4948fbc9246ae394750e49e.tar.xz
dpaa_eth: Fix kernel crash with timestamp support on
Recent changes in the driver moved the allocation of the skb on Rx past the point where the timestamp/1588 code used the skb. Reorder a bit the code to avoid NULL pointer dereferencing. Signed-off-by: Ioana Radulescu <ruxandra.radulescu@freescale.com> Change-Id: I09929c13bc88048be77c8678c1fb9956fec41039 Reviewed-on: http://git.am.freescale.net:8181/4443 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Bucur Madalin-Cristian-B32716 <madalin.bucur@freescale.com> Reviewed-by: Sovaiala Cristian-Constantin-B39531 <Cristian.Sovaiala@freescale.com> Reviewed-by: Rivera Jose-B46482 <German.Rivera@freescale.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c
index 70ee1c1..c950ea8 100644
--- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c
+++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c
@@ -265,17 +265,17 @@ static struct sk_buff *__hot contig_fd_to_skb(const struct dpa_priv_s *priv,
vaddr = phys_to_virt(addr);
+ /* Build the skb and adjust data and tail pointers */
+ skb = build_skb(vaddr, dpa_bp->size + DPA_SKB_TAILROOM);
+ if (unlikely(!skb))
+ return NULL;
+
/* do we need the timestamp for bad frames? */
#ifdef CONFIG_FSL_DPAA_1588
if (priv->tsu && priv->tsu->valid && priv->tsu->hwts_rx_en_ioctl)
dpa_ptp_store_rxstamp(priv, skb, vaddr);
#endif
- /* Build the skb and adjust data and tail pointers */
- skb = build_skb(vaddr, dpa_bp->size + DPA_SKB_TAILROOM);
- if (unlikely(!skb))
- return NULL;
-
/* Make sure forwarded skbs will have enough space on Tx,
* if extra headers are added.
*/
@@ -318,15 +318,6 @@ static struct sk_buff *__hot sg_fd_to_skb(const struct dpa_priv_s *priv,
int *count_ptr;
vaddr = phys_to_virt(addr);
-#ifdef CONFIG_FSL_DPAA_1588
- if (priv->tsu && priv->tsu->valid && priv->tsu->hwts_rx_en_ioctl)
- dpa_ptp_store_rxstamp(priv, skb, vaddr);
-#endif
-
-#ifdef CONFIG_FSL_DPAA_TS
- if (priv->ts_rx_en)
- dpa_get_ts(priv, RX, skb_hwtstamps(skb), vaddr);
-#endif /* CONFIG_FSL_DPAA_TS */
/* Iterate through the SGT entries and add data buffers to the skb */
sgt = vaddr + dpa_fd_offset(fd);
@@ -360,6 +351,17 @@ static struct sk_buff *__hot sg_fd_to_skb(const struct dpa_priv_s *priv,
*/
return NULL;
+#ifdef CONFIG_FSL_DPAA_1588
+ if (priv->tsu && priv->tsu->valid &&
+ priv->tsu->hwts_rx_en_ioctl)
+ dpa_ptp_store_rxstamp(priv, skb, vaddr);
+#endif
+
+#ifdef CONFIG_FSL_DPAA_TS
+ if (priv->ts_rx_en)
+ dpa_get_ts(priv, RX, skb_hwtstamps(skb), vaddr);
+#endif /* CONFIG_FSL_DPAA_TS */
+
dma_unmap_single(dpa_bp->dev, sg_addr, dpa_bp->size,
DMA_BIDIRECTIONAL);