]> git.baikalelectronics.ru Git - kernel.git/commit
net: qrtr: Allocate workqueue before kernel_bind
authorChris Lew <clew@codeaurora.org>
Thu, 28 May 2020 23:05:26 +0000 (16:05 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 31 May 2020 04:43:13 +0000 (21:43 -0700)
commit9ffda2b32c5e86fb6428a230e19fe4af2ef6d2ac
tree637c5291533ba491ca10187afee7d559924bc413
parent4f1cc7effd981bf06c98f2cc7e185c9b8dea21bc
net: qrtr: Allocate workqueue before kernel_bind

A null pointer dereference in qrtr_ns_data_ready() is seen if a client
opens a qrtr socket before qrtr_ns_init() can bind to the control port.
When the control port is bound, the ENETRESET error will be broadcasted
and clients will close their sockets. This results in DEL_CLIENT
packets being sent to the ns and qrtr_ns_data_ready() being called
without the workqueue being allocated.

Allocate the workqueue before setting sk_data_ready and binding to the
control port. This ensures that the work and workqueue structs are
allocated and initialized before qrtr_ns_data_ready can be called.

Fixes: c2942963826d ("net: qrtr: Migrate nameservice to kernel from userspace")
Signed-off-by: Chris Lew <clew@codeaurora.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/qrtr/ns.c