Skip to contentSkip to conversation

spi: spi-at91-usart: Fix wrong goto jump label when spi_alloc_master() returns error.

PATCH In review zpershuai 2 participants 2 messages Jun 9, 2021

Subsystems (3)
lore
Share & tools
lore

zpershuai

author
#0 lore raw

PATCH v2 1/1 spi: spi-at91-usart: Fix wrong goto jump label when spi_alloc_master() returns error.

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.

---
 drivers/spi/spi-at91-usart.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/spi/spi-at91-usart.c +1 -2
index 8c83526..e5c2d2c 100644
@@ -531,10 +531,9 @@ static int at91_usart_spi_probe(struct platform_device *pdev)
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
-	ret = -ENOMEM;
 	controller = spi_alloc_master(&pdev->dev, sizeof(*aus));
 	if (!controller)
-		goto at91_usart_spi_probe_fail;
+		return -ENOMEM;
 
 	ret = at91_usart_gpio_setup(pdev);
 	if (ret)
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 3 lines · 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.

So, I don't see the benefit in changing then.
at91_usart_spi_probe_fail label is nicely unified across the probe function and having it called once more or once less is no interest to me.

Sorry but NACK until someone persuades me it's needed or common pattern among spi drivers.

Regards,
Nicolas

Quoted 24 lines
---
  drivers/spi/spi-at91-usart.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/spi/spi-at91-usart.c +1 -3
index 8c83526..e5c2d2c 100644
@@ -531,10 +531,9 @@ static int at91_usart_spi_probe(struct platform_device *pdev)
         if (IS_ERR(clk))
                 return PTR_ERR(clk);
 
-       ret = -ENOMEM;
         controller = spi_alloc_master(&pdev->dev, sizeof(*aus));
         if (!controller)
-               goto at91_usart_spi_probe_fail;
+               return -ENOMEM;
 
         ret = at91_usart_gpio_setup(pdev);
         if (ret)
--

2.7.4

Signature · 1 line
Nicolas Ferre