linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: spi-at91-usart: Fix wrong goto jump label when spi_alloc_master() returns error.
@ 2021-06-08 15:14 zpershuai
  2021-06-08 22:46 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: zpershuai @ 2021-06-08 15:14 UTC (permalink / raw)
  To: Radu Pirea, Mark Brown, Nicolas Ferre, Alexandre Belloni,
	Ludovic Desroches, linux-spi, linux-arm-kernel, linux-kernel
  Cc: zpershuai

When spi_alloc_master() returns null pointer, it’s no need to use
spi_master_put() to release the memory, although spi_master_put()
function has null pointer checks.

Signed-off-by: zpershuai <zpershuai@gmail.com>
---
 drivers/spi/spi-at91-usart.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-at91-usart.c b/drivers/spi/spi-at91-usart.c
index 8c83526..c8136dc 100644
--- a/drivers/spi/spi-at91-usart.c
+++ b/drivers/spi/spi-at91-usart.c
@@ -533,8 +533,10 @@ static int at91_usart_spi_probe(struct platform_device *pdev)
 
 	ret = -ENOMEM;
 	controller = spi_alloc_master(&pdev->dev, sizeof(*aus));
-	if (!controller)
-		goto at91_usart_spi_probe_fail;
+	if (!controller) {
+		dev_err(&pdev->dev, "Error allocating SPI controller\n");
+		return -ENOMEM;
+	}
 
 	ret = at91_usart_gpio_setup(pdev);
 	if (ret)
-- 
2.7.4


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

* Re: [PATCH] spi: spi-at91-usart: Fix wrong goto jump label when spi_alloc_master() returns error.
  2021-06-08 15:14 [PATCH] spi: spi-at91-usart: Fix wrong goto jump label when spi_alloc_master() returns error zpershuai
@ 2021-06-08 22:46 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2021-06-08 22:46 UTC (permalink / raw)
  To: zpershuai
  Cc: Radu Pirea, Mark Brown, Nicolas Ferre, Ludovic Desroches,
	linux-spi, linux-arm-kernel, linux-kernel

On 08/06/2021 23:14:07+0800, zpershuai wrote:
> When spi_alloc_master() returns null pointer, it’s no need to use
> spi_master_put() to release the memory, although spi_master_put()
> function has null pointer checks.
> 
> Signed-off-by: zpershuai <zpershuai@gmail.com>
> ---
>  drivers/spi/spi-at91-usart.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/spi-at91-usart.c b/drivers/spi/spi-at91-usart.c
> index 8c83526..c8136dc 100644
> --- a/drivers/spi/spi-at91-usart.c
> +++ b/drivers/spi/spi-at91-usart.c
> @@ -533,8 +533,10 @@ static int at91_usart_spi_probe(struct platform_device *pdev)
>  
>  	ret = -ENOMEM;
>  	controller = spi_alloc_master(&pdev->dev, sizeof(*aus));
> -	if (!controller)
> -		goto at91_usart_spi_probe_fail;
> +	if (!controller) {
> +		dev_err(&pdev->dev, "Error allocating SPI controller\n");
> +		return -ENOMEM;
> +	}

size before this patch:
   text	   data	    bss	    dec	    hex	filename
   3659	    112	      0	   3771	    ebb	drivers/spi/spi-at91-usart.o

size after:
   text	   data	    bss	    dec	    hex	filename
   3671	    112	      0	   3783	    ec7	drivers/spi/spi-at91-usart.o

Please avoid adding useless error strings in the kernel. This will never
fail and if for some reason this fails an error message would already be
printed anyway.

Strings take space on the storage, increase boot time and RAM usage.

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

end of thread, other threads:[~2021-06-08 22:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 15:14 [PATCH] spi: spi-at91-usart: Fix wrong goto jump label when spi_alloc_master() returns error zpershuai
2021-06-08 22:46 ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).