All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] tty: serial: max3100: Add missing uart_unregister_driver in max3100_probe
@ 2022-05-11  7:15 Zheng Bin
  2022-05-11  9:38 ` Jiri Slaby
  2022-05-17 10:17 ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: Zheng Bin @ 2022-05-11  7:15 UTC (permalink / raw)
  To: gregkh, jirislaby, linux-serial, linux-kernel; +Cc: zhengbin13, gaochao49

max3100_probe misses a call uart_unregister_driver in error path,
this patch fixes that.

Signed-off-by: Zheng Bin <zhengbin13@huawei.com>
---
 drivers/tty/serial/max3100.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c
index 0b5f21fbb53d..6d34ca2a3f7b 100644
--- a/drivers/tty/serial/max3100.c
+++ b/drivers/tty/serial/max3100.c
@@ -752,6 +752,7 @@ static int max3100_probe(struct spi_device *spi)
 		if (!max3100s[i])
 			break;
 	if (i == MAX_MAX3100) {
+		uart_unregister_driver(&max3100_uart_driver);
 		dev_warn(&spi->dev, "too many MAX3100 chips\n");
 		mutex_unlock(&max3100s_lock);
 		return -ENOMEM;
@@ -759,6 +760,7 @@ static int max3100_probe(struct spi_device *spi)

 	max3100s[i] = kzalloc(sizeof(struct max3100_port), GFP_KERNEL);
 	if (!max3100s[i]) {
+		uart_unregister_driver(&max3100_uart_driver);
 		dev_warn(&spi->dev,
 			 "kmalloc for max3100 structure %d failed!\n", i);
 		mutex_unlock(&max3100s_lock);
--
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] tty: serial: max3100: Add missing uart_unregister_driver in max3100_probe
  2022-05-11  7:15 [PATCH -next] tty: serial: max3100: Add missing uart_unregister_driver in max3100_probe Zheng Bin
@ 2022-05-11  9:38 ` Jiri Slaby
  2022-05-17 10:17 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Slaby @ 2022-05-11  9:38 UTC (permalink / raw)
  To: Zheng Bin, gregkh, linux-serial, linux-kernel; +Cc: gaochao49

On 11. 05. 22, 9:15, Zheng Bin wrote:
> max3100_probe misses a call uart_unregister_driver in error path,
> this patch fixes that.

I believe, that's intentional. Cf. uart_driver_registered.

> Signed-off-by: Zheng Bin <zhengbin13@huawei.com>
> ---
>   drivers/tty/serial/max3100.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c
> index 0b5f21fbb53d..6d34ca2a3f7b 100644
> --- a/drivers/tty/serial/max3100.c
> +++ b/drivers/tty/serial/max3100.c
> @@ -752,6 +752,7 @@ static int max3100_probe(struct spi_device *spi)
>   		if (!max3100s[i])
>   			break;
>   	if (i == MAX_MAX3100) {
> +		uart_unregister_driver(&max3100_uart_driver);
>   		dev_warn(&spi->dev, "too many MAX3100 chips\n");
>   		mutex_unlock(&max3100s_lock);
>   		return -ENOMEM;
> @@ -759,6 +760,7 @@ static int max3100_probe(struct spi_device *spi)
> 
>   	max3100s[i] = kzalloc(sizeof(struct max3100_port), GFP_KERNEL);
>   	if (!max3100s[i]) {
> +		uart_unregister_driver(&max3100_uart_driver);
>   		dev_warn(&spi->dev,
>   			 "kmalloc for max3100 structure %d failed!\n", i);
>   		mutex_unlock(&max3100s_lock);
> --
> 2.31.1
> 


-- 
js
suse labs

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] tty: serial: max3100: Add missing uart_unregister_driver in max3100_probe
  2022-05-11  7:15 [PATCH -next] tty: serial: max3100: Add missing uart_unregister_driver in max3100_probe Zheng Bin
  2022-05-11  9:38 ` Jiri Slaby
@ 2022-05-17 10:17 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2022-05-17 10:17 UTC (permalink / raw)
  To: Zheng Bin; +Cc: jirislaby, linux-serial, linux-kernel, gaochao49

On Wed, May 11, 2022 at 03:15:23PM +0800, Zheng Bin wrote:
> max3100_probe misses a call uart_unregister_driver in error path,
> this patch fixes that.
> 
> Signed-off-by: Zheng Bin <zhengbin13@huawei.com>
> ---
>  drivers/tty/serial/max3100.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c
> index 0b5f21fbb53d..6d34ca2a3f7b 100644
> --- a/drivers/tty/serial/max3100.c
> +++ b/drivers/tty/serial/max3100.c
> @@ -752,6 +752,7 @@ static int max3100_probe(struct spi_device *spi)
>  		if (!max3100s[i])
>  			break;
>  	if (i == MAX_MAX3100) {
> +		uart_unregister_driver(&max3100_uart_driver);
>  		dev_warn(&spi->dev, "too many MAX3100 chips\n");
>  		mutex_unlock(&max3100s_lock);
>  		return -ENOMEM;
> @@ -759,6 +760,7 @@ static int max3100_probe(struct spi_device *spi)
> 
>  	max3100s[i] = kzalloc(sizeof(struct max3100_port), GFP_KERNEL);
>  	if (!max3100s[i]) {
> +		uart_unregister_driver(&max3100_uart_driver);
>  		dev_warn(&spi->dev,
>  			 "kmalloc for max3100 structure %d failed!\n", i);
>  		mutex_unlock(&max3100s_lock);

As Jiri said, this change would break the existing devices that are
registered with this driver.

How did you test this change?  What tool found this?  How was it
verified?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-17 10:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11  7:15 [PATCH -next] tty: serial: max3100: Add missing uart_unregister_driver in max3100_probe Zheng Bin
2022-05-11  9:38 ` Jiri Slaby
2022-05-17 10:17 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.