OSDN Git Service

net: ena: fix race between link up and device initalization
authorArthur Kiyanovski <akiyano@amazon.com>
Mon, 11 Feb 2019 17:17:43 +0000 (19:17 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 12 Feb 2019 19:05:07 +0000 (14:05 -0500)
commite1f1bd9bfbedcfce428ee7e1b82a6ec12d4c3863
tree630370599a4219dc5bbd400c691ef39d71782030
parentfc62814d690cf62189854464f4bd07457d5e9e50
net: ena: fix race between link up and device initalization

Fix race condition between ena_update_on_link_change() and
ena_restore_device().

This race can occur if link notification arrives while the driver
is performing a reset sequence. In this case link can be set up,
enabling the device, before it is fully restored. If packets are
sent at this time, the driver might access uninitialized data
structures, causing kernel crash.

Move the clearing of ENA_FLAG_ONGOING_RESET and netif_carrier_on()
after ena_up() to ensure the device is ready when link is set up.

Fixes: d18e4f683445 ("net: ena: fix race condition between device reset and link up setup")
Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/amazon/ena/ena_netdev.c