net: qrtr: Make qrtr_port_lookup() use RCU
authorBjorn Andersson <bjorn.andersson@linaro.org>
Tue, 14 Jan 2020 07:57:02 +0000 (23:57 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Jan 2020 02:36:42 +0000 (18:36 -0800)
commitf16a4b26f31f95dddb12cf3c2390906a735203ae
tree88a2188c8fb7fc91d2a41ac4ab6ed5e98acbf304
parent0a7e0d0ef05440db03c3199e84d228db943b237f
net: qrtr: Make qrtr_port_lookup() use RCU

The important part of qrtr_port_lookup() wrt synchronization is that the
function returns a reference counted struct qrtr_sock, or fail.

As such we need only to ensure that an decrement of the object's
refcount happens inbetween the finding of the object in the idr and
qrtr_port_lookup()'s own increment of the object.

By using RCU and putting a synchronization point after we remove the
mapping from the idr, but before it can be released we achieve this -
with the benefit of not having to hold the mutex in qrtr_port_lookup().

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/qrtr/qrtr.c