LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] pwm: omap-dmtimer: Add missing put_device() call in pwm_omap_dmtimer_probe()
@ 2019-11-09 12:26 Markus Elfring
  2019-11-11  7:19 ` Uwe Kleine-König
  0 siblings, 1 reply; 18+ messages in thread
From: Markus Elfring @ 2019-11-09 12:26 UTC (permalink / raw)
  To: linux-pwm, Claudiu Beznea, Keerthy, Neil Armstrong,
	Thierry Reding, Tony Lindgren, Uwe Kleine-König
  Cc: LKML, kernel-janitors, Grant Erickson, Joachim Eastwood,
	Neil Brown, Wen Yang

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 9 Nov 2019 13:09:42 +0100

A coccicheck run provided information like the following.

drivers/pwm/pwm-omap-dmtimer.c:304:2-8: ERROR: missing put_device;
call of_find_device_by_node on line 255, but without a corresponding
object release within this function.

Generated by: scripts/coccinelle/free/put_device.cocci

Thus add jump targets to fix the exception handling for this
function implementation.

Fixes: b7290cf6ff7869ec12070aa146c370728cab62c2 ("pwm: pwm-omap-dmtimer: Adapt driver to utilize dmtimer pdata ops")
Fixes: 6604c6556db9e41c85f2839f66bd9d617bcf9f87 ("pwm: Add PWM driver for OMAP using dual-mode timers")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pwm/pwm-omap-dmtimer.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/pwm-omap-dmtimer.c b/drivers/pwm/pwm-omap-dmtimer.c
index 00772fc53490..958854213786 100644
--- a/drivers/pwm/pwm-omap-dmtimer.c
+++ b/drivers/pwm/pwm-omap-dmtimer.c
@@ -301,12 +301,13 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 put:
 	of_node_put(timer);
 	if (ret < 0)
-		return ret;
+		goto check_timer_pdev;

 	omap = devm_kzalloc(&pdev->dev, sizeof(*omap), GFP_KERNEL);
 	if (!omap) {
 		pdata->free(dm_timer);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto put_device;
 	}

 	omap->pdata = pdata;
@@ -340,12 +341,19 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed to register PWM\n");
 		omap->pdata->free(omap->dm_timer);
-		return ret;
+		goto put_device;
 	}

 	platform_set_drvdata(pdev, omap);

 	return 0;
+
+check_timer_pdev:
+	if (timer_pdev)
+put_device:
+		put_device(&timer_pdev->dev);
+
+	return ret;
 }

 static int pwm_omap_dmtimer_remove(struct platform_device *pdev)
--
2.24.0


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

end of thread, back to index

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-09 12:26 [PATCH] pwm: omap-dmtimer: Add missing put_device() call in pwm_omap_dmtimer_probe() Markus Elfring
2019-11-11  7:19 ` Uwe Kleine-König
     [not found]   ` <20191111090357.13903-1-u.kleine-koenig@pengutronix.de>
     [not found]     ` <20191111091606.qf7gj5gln3khfnsl@pengutronix.de>
2019-11-11 13:28       ` [0/4] pwm: omap-dmtimer: Software improvements Markus Elfring
2019-11-11 13:28       ` Markus Elfring
2019-11-11 19:57         ` Uwe Kleine-König
2019-11-11 13:30     ` [PATCH 1/4] pwm: omap-dmtimer: remove pwmchip in .remove before making it unfunctional Markus Elfring
2019-11-11 20:00       ` Uwe Kleine-König
2019-11-11 21:00         ` [1/4] " Markus Elfring
     [not found]     ` <20191111090357.13903-2-u.kleine-koenig@pengutronix.de>
2019-11-11 13:32       ` [PATCH 2/4] pwm: omap-dmtimer: simplify error handling Markus Elfring
2019-11-11 20:08         ` Uwe Kleine-König
2019-11-11 21:30           ` Markus Elfring
     [not found]     ` <20191111090357.13903-3-u.kleine-koenig@pengutronix.de>
2019-11-11 13:41       ` [PATCH 3/4] pwm: omap-dmtimer: put_device() after of_find_device_by_node() Markus Elfring
2019-11-11 20:09         ` Uwe Kleine-König
2019-11-11 21:38           ` [3/4] " Markus Elfring
2019-11-11 21:46             ` Uwe Kleine-König
2019-11-12  7:40               ` Markus Elfring
     [not found]     ` <20191111090357.13903-4-u.kleine-koenig@pengutronix.de>
2019-11-11 13:47       ` [PATCH 4/4] pwm: omap-dmtimer: Allow compiling with COMPILE_TEST Markus Elfring
2019-11-11 13:47       ` Markus Elfring

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git