can: sja1000: don't touch skb after netif_rx()

There is no guarantee that the skb is in the same state after calling
net_receive_skb() or netif_rx(). It might be freed or reused. Not really
harmful as its a read access, except you turn on the proper debugging options
which catch a use after free.

Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
Marc Kleine-Budde 2015-07-11 21:16:08 +02:00
Родитель ef934e89f5
Коммит 889dd06e10
1 изменённых файлов: 2 добавлений и 4 удалений

Просмотреть файл

@ -377,10 +377,9 @@ static void sja1000_rx(struct net_device *dev)
/* release receive buffer */ /* release receive buffer */
sja1000_write_cmdreg(priv, CMD_RRB); sja1000_write_cmdreg(priv, CMD_RRB);
netif_rx(skb);
stats->rx_packets++; stats->rx_packets++;
stats->rx_bytes += cf->can_dlc; stats->rx_bytes += cf->can_dlc;
netif_rx(skb);
can_led_event(dev, CAN_LED_EVENT_RX); can_led_event(dev, CAN_LED_EVENT_RX);
} }
@ -484,10 +483,9 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
can_bus_off(dev); can_bus_off(dev);
} }
netif_rx(skb);
stats->rx_packets++; stats->rx_packets++;
stats->rx_bytes += cf->can_dlc; stats->rx_bytes += cf->can_dlc;
netif_rx(skb);
return 0; return 0;
} }