Skip to contentSkip to conversation

spi: tegra114: missing put on pm_runtime_get_sync failure

PATCH In review Navid Emamdoost 2 participants 3 messages Jun 2, 2020 – Jun 5, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: tegra114: missing put on pm_runtime_get_sync failure

the call to pm_runtime_get_sync increments the counter even in case of failure leading to incorrect ref count. Call pm_runtime_put if pm_runtime_get_sync fails.

---
 drivers/spi/spi-tegra114.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/spi/spi-tegra114.c +3 -0
index 83edabdb41ad..dccd2ac1a975 100644
@@ -974,6 +974,7 @@ static int tegra_spi_setup(struct spi_device *spi)
 		dev_err(tspi->dev, "pm runtime failed, e = %d\n", ret);
 		if (cdata)
 			tegra_spi_cleanup(spi);
+		pm_runtime_put(tspi->dev);
 		return ret;
 	}
 
@@ -1398,6 +1399,7 @@ static int tegra_spi_probe(struct platform_device *pdev)
 	ret = pm_runtime_get_sync(&pdev->dev);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "pm runtime get failed, e = %d\n", ret);
+		pm_runtime_put(&pdev->dev);
 		goto exit_pm_disable;
 	}
 
@@ -1479,6 +1481,7 @@ static int tegra_spi_resume(struct device *dev)
 	ret = pm_runtime_get_sync(dev);
 	if (ret < 0) {
 		dev_err(dev, "pm runtime failed, e = %d\n", ret);
+		pm_runtime_put(dev);
 		return ret;
 	}
 	tegra_spi_writel(tspi, tspi->command1_reg, SPI_COMMAND1);
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 22 lines · Navid Emamdoost

the call to pm_runtime_get_sync increments the counter even in case of failure leading to incorrect ref count. Call pm_runtime_put if pm_runtime_get_sync fails.

---
 drivers/spi/spi-tegra114.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/spi/spi-tegra114.c +1 -0
index 83edabdb41ad..dccd2ac1a975 100644
@@ -974,6 +974,7 @@ static int tegra_spi_setup(struct spi_device *spi)
 		dev_err(tspi->dev, "pm runtime failed, e = %d\n", ret);
 		if (cdata)
 			tegra_spi_cleanup(spi);
+		pm_runtime_put(tspi->dev);
 		return ret;
 	}
 

drivers/spi/spi-tegra114.c static int tegra_spi_probe(struct platform_device *pdev) · line 1404

Quoted 6 lines
drivers/spi/spi-tegra114.c +1 -0
@@ -1398,6 +1399,7 @@ static int tegra_spi_probe(struct platform_device *pdev)
 	ret = pm_runtime_get_sync(&pdev->dev);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "pm runtime get failed, e = %d\n", ret);
+		pm_runtime_put(&pdev->dev);
 		goto exit_pm_disable;
 	}

I am wondering if it is better we use put_sync() here to ensure that this happens before we exit the probe.

Jon

Signature · 1 line
nvpublic
#2 lore raw
Quoted 24 lines · Jon Hunter
Quoted 21 lines · Navid Emamdoost

the call to pm_runtime_get_sync increments the counter even in case of failure leading to incorrect ref count. Call pm_runtime_put if pm_runtime_get_sync fails.

---
 drivers/spi/spi-tegra114.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/spi/spi-tegra114.c +1 -0
index 83edabdb41ad..dccd2ac1a975 100644
@@ -974,6 +974,7 @@ static int tegra_spi_setup(struct spi_device *spi)
              dev_err(tspi->dev, "pm runtime failed, e = %d\n", ret);
              if (cdata)
                      tegra_spi_cleanup(spi);
+             pm_runtime_put(tspi->dev);
              return ret;
      }
 
Quoted 10 lines

drivers/spi/spi-tegra114.c static int tegra_spi_probe(struct platform_device *pdev) · line 1404

Quoted 7 lines
drivers/spi/spi-tegra114.c +1 -0
@@ -1398,6 +1399,7 @@ static int tegra_spi_probe(struct platform_device *pdev)
      ret = pm_runtime_get_sync(&pdev->dev);
      if (ret < 0) {
              dev_err(&pdev->dev, "pm runtime get failed, e = %d\n", ret);
+             pm_runtime_put(&pdev->dev);
              goto exit_pm_disable;
      }

I am wondering if it is better we use put_sync() here to ensure that this happens before we exit the probe.

To be honest I am not sure when to use different flavors of pm_runtime_put (like pm_runtime_put_noidle, pm_runtime_put_autosuspend, pm_runtime_put_sync, pm_runtime_put, pm_runtime_put_sync_suspend). I'd appreciate it if you could give me a pointer on how to decide on this.

Quoted 5 lines

Jon

--
nvpublic

Signature · 1 line
Navid.