OSDN Git Service

qede: Fix race between rdma destroy workqueue and link change event
authorMichal Kalderon <michal.kalderon@marvell.com>
Mon, 17 Feb 2020 11:37:18 +0000 (13:37 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 18 Feb 2020 20:05:53 +0000 (12:05 -0800)
commitaf6565adb02d3129d3fae4d9d5da945abaf4417a
tree4ed0a834f46cc36f7e8a3e3ff34b1b0b48396976
parent9b64208f74fbd0e920475ecfe9326f8443fdc3a5
qede: Fix race between rdma destroy workqueue and link change event

If an event is added while the rdma workqueue is being destroyed
it could lead to several races, list corruption, null pointer
dereference during queue_work or init_queue.
This fixes the race between the two flows which can occur during
shutdown.

A kref object and a completion object are added to the rdma_dev
structure, these are initialized before the workqueue is created.
The refcnt is used to indicate work is being added to the
workqueue and ensures the cleanup flow won't start while we're in
the middle of adding the event.
Once the work is added, the refcnt is decreased and the cleanup flow
is safe to run.

Fixes: cee9fbd8e2e ("qede: Add qedr framework")
Signed-off-by: Ariel Elior <ariel.elior@marvell.com>
Signed-off-by: Michal Kalderon <michal.kalderon@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qede/qede.h
drivers/net/ethernet/qlogic/qede/qede_rdma.c