rmnet_unregister_real_device() tears down the aggregation state before unregistering the rx handler. When the last vnd on a port is deleted, that vnd is still registered and the egress path still finds the port through rx_handler_data, so a transmit can start an aggregate and arm the timer. The port is then freed: the timer fires on freed memory and the aggregate leaks. Reproducer: ip link add link v0 name rmnet1 type rmnet mux_id 1 ethtool -C rmnet1 tx-aggr-max-frames 64 tx-aggr-max-bytes 4096 \ tx-aggr-time-usecs 1000000 then delete rmnet1 while flooding UDP through it from all CPUs. DEBUG_OBJECTS_TIMERS reports "ODEBUG: free active object type: hrtimer", KASAN a use-after-free once the timer fires. Unregister the rx handler first: after its RCU grace period no transmit can find the port. Fixes: 64b5d1f8f2d1 ("net: qualcomm: rmnet: add tx packets aggregation") Signed-off-by: Antonio Quartulli --- drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c index 61b04c6c0390..2ff4b9519139 100644 --- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c +++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c @@ -40,10 +40,10 @@ static int rmnet_unregister_real_device(struct net_device *real_dev) if (port->nr_rmnet_devs) return -EINVAL; - rmnet_map_tx_aggregate_exit(port); - netdev_rx_handler_unregister(real_dev); + rmnet_map_tx_aggregate_exit(port); + kfree(port); netdev_dbg(real_dev, "Removed from rmnet\n"); -- 2.56.1