diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index edb6ac17ceca..f2d4d571be39 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -5,6 +5,7 @@ */ #include #include +#include #include #include /* For TIOCINQ/OUTQ */ #include @@ -722,17 +723,23 @@ static int qrtr_port_assign(struct qrtr_sock *ipc, int *port) mutex_lock(&qrtr_port_lock); if (!*port) { min_port = QRTR_MIN_EPH_SOCKET; + preempt_disable(); rc = idr_alloc_u32(&qrtr_ports, ipc, &min_port, QRTR_MAX_EPH_SOCKET, GFP_ATOMIC); + preempt_enable(); if (!rc) *port = min_port; } else if (*port < QRTR_MIN_EPH_SOCKET && !capable(CAP_NET_ADMIN)) { rc = -EACCES; } else if (*port == QRTR_PORT_CTRL) { min_port = 0; + preempt_disable(); rc = idr_alloc_u32(&qrtr_ports, ipc, &min_port, 0, GFP_ATOMIC); + preempt_enable(); } else { min_port = *port; + preempt_disable(); rc = idr_alloc_u32(&qrtr_ports, ipc, &min_port, *port, GFP_ATOMIC); + preempt_enable(); if (!rc) *port = min_port; }