All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: systemport: Guard against unmapped TX ring
@ 2017-10-20 22:59 Florian Fainelli
  2017-10-23  4:29 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Fainelli @ 2017-10-20 22:59 UTC (permalink / raw)
  To: netdev; +Cc: davem, Florian Fainelli

Because SYSTEMPORT is a (semi) normal network device, the stack may attempt to
queue packets on it oustide of the DSA slave transmit path.  When that happens,
the DSA layer has not had a chance to tag packets with the appropriate per-port
and per-queue information, and if that happens and we don't have a port 0 queue
0 available (e.g: on boards where this does not exist), we will hit a NULL
pointer de-reference in bcm_sysport_select_queue().

Guard against such cases by testing for the TX ring validity.

Fixes: 84ff33eeb23d ("net: systemport: Establish DSA network device queue mapping")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/broadcom/bcmsysport.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index dafc26690555..1d9d5f986e14 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -2040,6 +2040,9 @@ static u16 bcm_sysport_select_queue(struct net_device *dev, struct sk_buff *skb,
 	port = BRCM_TAG_GET_PORT(queue);
 	tx_ring = priv->ring_map[q + port * priv->per_port_num_tx_queues];
 
+	if (unlikely(!tx_ring))
+		return fallback(dev, skb);
+
 	return tx_ring->index;
 }
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] net: systemport: Guard against unmapped TX ring
  2017-10-20 22:59 [PATCH net-next] net: systemport: Guard against unmapped TX ring Florian Fainelli
@ 2017-10-23  4:29 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-10-23  4:29 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Fri, 20 Oct 2017 15:59:30 -0700

> Because SYSTEMPORT is a (semi) normal network device, the stack may attempt to
> queue packets on it oustide of the DSA slave transmit path.  When that happens,
> the DSA layer has not had a chance to tag packets with the appropriate per-port
> and per-queue information, and if that happens and we don't have a port 0 queue
> 0 available (e.g: on boards where this does not exist), we will hit a NULL
> pointer de-reference in bcm_sysport_select_queue().
> 
> Guard against such cases by testing for the TX ring validity.
> 
> Fixes: 84ff33eeb23d ("net: systemport: Establish DSA network device queue mapping")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-23  4:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-20 22:59 [PATCH net-next] net: systemport: Guard against unmapped TX ring Florian Fainelli
2017-10-23  4:29 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.