diff options
author | Ioana Radulescu <ruxandra.radulescu@freescale.com> | 2013-08-28 15:24:34 (GMT) |
---|---|---|
committer | Rivera Jose-B46482 <German.Rivera@freescale.com> | 2013-09-20 18:58:42 (GMT) |
commit | 962704315ce021e0cac8166e2c6959bff18d7ac4 (patch) | |
tree | 41e46f7f33affbbb2137399ed2a7d78a37a2f813 /drivers/net/ethernet | |
parent | 4d3653b4916d70adc727c42d3e348ae0ef0aa19f (diff) | |
download | linux-fsl-qoriq-962704315ce021e0cac8166e2c6959bff18d7ac4.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: I65acb8f1a055d925434a5361ca4570032bae9047
Reviewed-on: http://git.am.freescale.net:8181/4841
Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com>
Reviewed-by: Cristian-Constantin Sovaiala <Cristian.Sovaiala@freescale.com>
Reviewed-by: Bucur Madalin-Cristian-B32716 <madalin.bucur@freescale.com>
Reviewed-by: Rivera Jose-B46482 <German.Rivera@freescale.com>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r-- | drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c index 04a2de3..fff3926 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_sg.c @@ -337,12 +337,6 @@ static struct sk_buff *__hot contig_fd_to_skb(const struct dpa_priv_s *priv, vaddr = phys_to_virt(addr); DPA_BUG_ON(!IS_ALIGNED((unsigned long)vaddr, SMP_CACHE_BYTES)); - /* 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, to make sure * forwarded skbs will have enough space on Tx if extra headers * are added. @@ -356,6 +350,12 @@ static struct sk_buff *__hot contig_fd_to_skb(const struct dpa_priv_s *priv, 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 + DPA_BUG_ON(fd_off != priv->rx_headroom); skb_reserve(skb, fd_off); skb_put(skb, dpa_fd_length(fd)); @@ -398,15 +398,6 @@ static struct sk_buff *__hot sg_fd_to_skb(const struct dpa_priv_s *priv, vaddr = phys_to_virt(addr); DPA_BUG_ON(!IS_ALIGNED((unsigned long)vaddr, SMP_CACHE_BYTES)); -#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 + fd_off; @@ -445,6 +436,16 @@ static struct sk_buff *__hot sg_fd_to_skb(const struct dpa_priv_s *priv, dma_unmap_single(dpa_bp->dev, sg_addr, dpa_bp->size, DMA_BIDIRECTIONAL); +#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 */ + /* In the case of a SG frame, FMan stores the Internal * Context in the buffer containing the sgt. * Inspect the parse results before anything else. |