tty/serial: digicolor: Fix digicolor-usart already registered warning [Linux 4.9.187]

This Linux kernel change "tty/serial: digicolor: Fix digicolor-usart already registered warning" is included in the Linux 4.9.187 release. This change is authored by Kefeng Wang < [at]> on Fri May 31 21:37:33 2019 +0800. The commit for this change in Linux stable tree is 483aca9 (patch) which is from upstream commit c7ad9ba. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream c7ad9ba.

tty/serial: digicolor: Fix digicolor-usart already registered warning

[ Upstream commit c7ad9ba0611c53cfe194223db02e3bca015f0674 ]

When modprobe/rmmod/modprobe module, if platform_driver_register() fails,
the kernel complained,

  proc_dir_entry 'driver/digicolor-usart' already registered
  WARNING: CPU: 1 PID: 5636 at fs/proc/generic.c:360 proc_register+0x19d/0x270

Fix this by adding uart_unregister_driver() when platform_driver_register() fails.

Reported-by: Hulk Robot <>
Signed-off-by: Kefeng Wang <>
Acked-by: Baruch Siach <>
Signed-off-by: Greg Kroah-Hartman <>
Signed-off-by: Sasha Levin <>

There are 6 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/tty/serial/digicolor-usart.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/digicolor-usart.c b/drivers/tty/serial/digicolor-usart.c
index 02ad695..50ec5f1 100644
--- a/drivers/tty/serial/digicolor-usart.c
+++ b/drivers/tty/serial/digicolor-usart.c
@@ -545,7 +545,11 @@ static int __init digicolor_uart_init(void)
    if (ret)
        return ret;

-   return platform_driver_register(&digicolor_uart_platform);
+   ret = platform_driver_register(&digicolor_uart_platform);
+   if (ret)
+       uart_unregister_driver(&digicolor_uart);
+   return ret;

Leave a Reply

Your email address will not be published. Required fields are marked *