Skip to contentSkip to conversation

serial: core: Don't drop port_mutex in serial_core_remove_one_port

PATCH In review Steven Price 2 participants 2 messages Jun 1, 2023 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: core: Don't drop port_mutex in serial_core_remove_one_port

Commit 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM") required the caller to hold port_mutex rather than taking it locally. However the mutex_unlock() call wasn't removed causing the mutex to be dropped unexpectly. Remove the call to mutex_unlock() (and fix up the early return) to restore correct behaviour.

Fixes 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM")
---
 drivers/tty/serial/serial_core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/tty/serial/serial_core.c +1 -3
index 29bd5ede0b25..efda90215ee9 100644
@@ -3194,7 +3194,7 @@ static void serial_core_remove_one_port(struct uart_driver *drv,
 
 	if (!uart_port) {
 		mutex_unlock(&port->mutex);
-		goto out;
+		return;
 	}
 	mutex_unlock(&port->mutex);
 
@@ -3234,8 +3234,6 @@ static void serial_core_remove_one_port(struct uart_driver *drv,
 	wait_event(state->remove_wait, !atomic_read(&state->refcount));
 	state->uart_port = NULL;
 	mutex_unlock(&port->mutex);
-out:
-	mutex_unlock(&port_mutex);
 }
 
 /**
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Steven Price

Commit 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM") required the caller to hold port_mutex rather than taking it locally. However the mutex_unlock() call wasn't removed causing the mutex to be dropped unexpectly. Remove the call to mutex_unlock() (and fix up the early return) to restore correct behaviour.

Fixes 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM")