Patch "serial: cpm_uart: Avoid suspicious locking" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    serial: cpm_uart: Avoid suspicious locking

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     serial-cpm_uart-avoid-suspicious-locking.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 3939c046f21125cb1ad4ca3cf6aac12f14c5d545
Author: Christophe Leroy <christophe.leroy@xxxxxxxxxx>
Date:   Thu Aug 3 15:56:42 2023 +0200

    serial: cpm_uart: Avoid suspicious locking
    
    [ Upstream commit 36ef11d311f405e55ad8e848c19b212ff71ef536 ]
    
      CHECK   drivers/tty/serial/cpm_uart/cpm_uart_core.c
    drivers/tty/serial/cpm_uart/cpm_uart_core.c:1271:39: warning: context imbalance in 'cpm_uart_console_write' - unexpected unlock
    
    Allthough 'nolock' is not expected to change, sparse find the following
    form suspicious:
    
            if (unlikely(nolock)) {
                    local_irq_save(flags);
            } else {
                    spin_lock_irqsave(&pinfo->port.lock, flags);
            }
    
            cpm_uart_early_write(pinfo, s, count, true);
    
            if (unlikely(nolock)) {
                    local_irq_restore(flags);
            } else {
                    spin_unlock_irqrestore(&pinfo->port.lock, flags);
            }
    
    Rewrite it a more obvious form:
    
            if (unlikely(oops_in_progress)) {
                    local_irq_save(flags);
                    cpm_uart_early_write(pinfo, s, count, true);
                    local_irq_restore(flags);
            } else {
                    spin_lock_irqsave(&pinfo->port.lock, flags);
                    cpm_uart_early_write(pinfo, s, count, true);
                    spin_unlock_irqrestore(&pinfo->port.lock, flags);
            }
    
    Signed-off-by: Christophe Leroy <christophe.leroy@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/f7da5cdc9287960185829cfef681a7d8614efa1f.1691068700.git.christophe.leroy@xxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index b4369ed45ae2d..bb25691f50007 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -1257,19 +1257,14 @@ static void cpm_uart_console_write(struct console *co, const char *s,
 {
 	struct uart_cpm_port *pinfo = &cpm_uart_ports[co->index];
 	unsigned long flags;
-	int nolock = oops_in_progress;
 
-	if (unlikely(nolock)) {
+	if (unlikely(oops_in_progress)) {
 		local_irq_save(flags);
-	} else {
-		spin_lock_irqsave(&pinfo->port.lock, flags);
-	}
-
-	cpm_uart_early_write(pinfo, s, count, true);
-
-	if (unlikely(nolock)) {
+		cpm_uart_early_write(pinfo, s, count, true);
 		local_irq_restore(flags);
 	} else {
+		spin_lock_irqsave(&pinfo->port.lock, flags);
+		cpm_uart_early_write(pinfo, s, count, true);
 		spin_unlock_irqrestore(&pinfo->port.lock, flags);
 	}
 }



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux