Skip to contentSkip to conversation

drivers/thermal/qcom/tsens.c:123:1-7: ERROR: missing put_device; call of_find_device_by_node on line 103, but without a corresponding object release within this function. (fwd)

PATCH In review Julia Lawall 3 participants 5 messages Oct 17, 2019 – Oct 18, 2019

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

PATCH 11/16 drivers/thermal/qcom/tsens.c:123:1-7: ERROR: missing put_device; call of_find_device_by_node on line 103, but without a corresponding object release within this function. (fwd)

Hello,

Perhaps pdev should be released or save somewhere before leaving the function.

If this is a false positive, I can update the rule.

julia

---------- Forwarded message ----------
Date: Thu, 17 Oct 2019 18:06:41 +0800
From: kbuild test robot <[email protected]>
To: kbuild(a)lists.01.org
Cc: Julia Lawall <[email protected]>
Subject: [daniel.lezcano:thermal/linux-next 11/16]
drivers/thermal/qcom/tsens.c:123:1-7: ERROR: missing put_device; call of_find_device_by_node on line 103,
but without a corresponding object release within this function.

CC: kbuild-all(a)lists.01.org
TO: Amit Kucheria <[email protected]>
CC: Daniel Lezcano <[email protected]>
CC: Stephen Boyd <[email protected]>

tree:   http://git.linaro.org/people/daniel.lezcano/linux thermal/linux-next
head:   124d92b700811381a477ca6b38d1c98417894f0e
commit: cd376943ac255b0b0b299307c12f6bdb28b825a2 [11/16] drivers: thermal: tsens: Add interrupt support

:::::: branch date: 16 hours ago
:::::: commit date: 25 hours ago

If you fix the issue, kindly add following tag

Quoted 1 line
Quoted 1 line

drivers/thermal/qcom/tsens.c:123:1-7: ERROR: missing put_device; call of_find_device_by_node on line 103, but without a corresponding object release within this function.

git remote add daniel.lezcano http://git.linaro.org/people/daniel.lezcano/linux
git remote update daniel.lezcano
git checkout cd376943ac255b0b0b299307c12f6bdb28b825a2
vim +123 drivers/thermal/qcom/tsens.c

9066073c6c2799 Rajendra Nayak 2016-05-05   84
69b628ac71f07d Amit Kucheria  2019-03-20   85  static int tsens_register(struct tsens_priv *priv)
9066073c6c2799 Rajendra Nayak 2016-05-05   86  {
cd376943ac255b Amit Kucheria  2019-10-16   87  	int i, ret, irq;
9066073c6c2799 Rajendra Nayak 2016-05-05   88  	struct thermal_zone_device *tzd;
cd376943ac255b Amit Kucheria  2019-10-16   89  	struct platform_device *pdev;
9066073c6c2799 Rajendra Nayak 2016-05-05   90
69b628ac71f07d Amit Kucheria  2019-03-20   91  	for (i = 0;  i < priv->num_sensors; i++) {
69b628ac71f07d Amit Kucheria  2019-03-20   92  		priv->sensor[i].priv = priv;
3e68159d5fdf29 Amit Kucheria  2019-10-16   93  		tzd = devm_thermal_zone_of_sensor_register(priv->dev, priv->sensor[i].hw_id,
69b628ac71f07d Amit Kucheria  2019-03-20   94  							   &priv->sensor[i],
9066073c6c2799 Rajendra Nayak 2016-05-05   95  							   &tsens_of_ops);
9066073c6c2799 Rajendra Nayak 2016-05-05   96  		if (IS_ERR(tzd))
9066073c6c2799 Rajendra Nayak 2016-05-05   97  			continue;
69b628ac71f07d Amit Kucheria  2019-03-20   98  		priv->sensor[i].tzd = tzd;
69b628ac71f07d Amit Kucheria  2019-03-20   99  		if (priv->ops->enable)
69b628ac71f07d Amit Kucheria  2019-03-20  100  			priv->ops->enable(priv, i);
9066073c6c2799 Rajendra Nayak 2016-05-05  101  	}
cd376943ac255b Amit Kucheria  2019-10-16  102
cd376943ac255b Amit Kucheria  2019-10-16 @103  	pdev = of_find_device_by_node(priv->dev->of_node);
cd376943ac255b Amit Kucheria  2019-10-16  104  	if (!pdev)
cd376943ac255b Amit Kucheria  2019-10-16  105  		return -ENODEV;
cd376943ac255b Amit Kucheria  2019-10-16  106
cd376943ac255b Amit Kucheria  2019-10-16  107  	irq = platform_get_irq_byname(pdev, "uplow");
cd376943ac255b Amit Kucheria  2019-10-16  108  	if (irq < 0) {
cd376943ac255b Amit Kucheria  2019-10-16  109  		ret = irq;
cd376943ac255b Amit Kucheria  2019-10-16  110  		goto err_put_device;
cd376943ac255b Amit Kucheria  2019-10-16  111  	}
cd376943ac255b Amit Kucheria  2019-10-16  112
cd376943ac255b Amit Kucheria  2019-10-16  113  	ret = devm_request_threaded_irq(&pdev->dev, irq,
cd376943ac255b Amit Kucheria  2019-10-16  114  					NULL, tsens_irq_thread,
cd376943ac255b Amit Kucheria  2019-10-16  115  					IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
cd376943ac255b Amit Kucheria  2019-10-16  116  					dev_name(&pdev->dev), priv);
cd376943ac255b Amit Kucheria  2019-10-16  117  	if (ret) {
cd376943ac255b Amit Kucheria  2019-10-16  118  		dev_err(&pdev->dev, "%s: failed to get irq\n", __func__);
cd376943ac255b Amit Kucheria  2019-10-16  119  		goto err_put_device;
cd376943ac255b Amit Kucheria  2019-10-16  120  	}
cd376943ac255b Amit Kucheria  2019-10-16  121
cd376943ac255b Amit Kucheria  2019-10-16  122  	enable_irq_wake(irq);
9066073c6c2799 Rajendra Nayak 2016-05-05 @123  	return 0;
cd376943ac255b Amit Kucheria  2019-10-16  124
cd376943ac255b Amit Kucheria  2019-10-16  125  err_put_device:
cd376943ac255b Amit Kucheria  2019-10-16  126  	put_device(&pdev->dev);
cd376943ac255b Amit Kucheria  2019-10-16  127  	return ret;
9066073c6c2799 Rajendra Nayak 2016-05-05  128  }
9066073c6c2799 Rajendra Nayak 2016-05-05  129

:::::: The code at line 123 was first introduced by commit
:::::: 9066073c6c27994a30187abf3b674770b4088348 thermal: qcom: tsens: Add a skeletal TSENS drivers

:::::: TO: Rajendra Nayak <[email protected]>
:::::: CC: Zhang Rui <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#1 lore raw
Quoted 9 lines · Julia Lawall

Hello,

Perhaps pdev should be released or save somewhere before leaving the function.

If this is a false positive, I can update the rule.

julia

Thanks for the report, Julia.

I believe the following patch fixes this issue. Can you confirm?

Daniel, would you like me to respin the series with this fix squashed or will you take this patch on top of thermal-next?

Regards,
Amit

Quoted 82 lines

---------- Forwarded message ----------
Date: Thu, 17 Oct 2019 18:06:41 +0800
From: kbuild test robot <[email protected]>
To: kbuild(a)lists.01.org
Cc: Julia Lawall <[email protected]>
Subject: [daniel.lezcano:thermal/linux-next 11/16]
drivers/thermal/qcom/tsens.c:123:1-7: ERROR: missing put_device; call of_find_device_by_node on line 103,
but without a corresponding object release within this function.

CC: kbuild-all(a)lists.01.org
TO: Amit Kucheria <[email protected]>
CC: Daniel Lezcano <[email protected]>
CC: Stephen Boyd <[email protected]>

tree:   http://git.linaro.org/people/daniel.lezcano/linux thermal/linux-next
head:   124d92b700811381a477ca6b38d1c98417894f0e
commit: cd376943ac255b0b0b299307c12f6bdb28b825a2 [11/16] drivers: thermal: tsens: Add interrupt support

:::::: branch date: 16 hours ago
:::::: commit date: 25 hours ago

If you fix the issue, kindly add following tag

Quoted 1 line
Quoted 1 line

drivers/thermal/qcom/tsens.c:123:1-7: ERROR: missing put_device; call of_find_device_by_node on line 103, but without a corresponding object release within this function.

git remote add daniel.lezcano http://git.linaro.org/people/daniel.lezcano/linux
git remote update daniel.lezcano
git checkout cd376943ac255b0b0b299307c12f6bdb28b825a2
vim +123 drivers/thermal/qcom/tsens.c

9066073c6c2799 Rajendra Nayak 2016-05-05   84
69b628ac71f07d Amit Kucheria  2019-03-20   85  static int tsens_register(struct tsens_priv *priv)
9066073c6c2799 Rajendra Nayak 2016-05-05   86  {
cd376943ac255b Amit Kucheria  2019-10-16   87   int i, ret, irq;
9066073c6c2799 Rajendra Nayak 2016-05-05   88   struct thermal_zone_device *tzd;
cd376943ac255b Amit Kucheria  2019-10-16   89   struct platform_device *pdev;
9066073c6c2799 Rajendra Nayak 2016-05-05   90
69b628ac71f07d Amit Kucheria  2019-03-20   91   for (i = 0;  i < priv->num_sensors; i++) {
69b628ac71f07d Amit Kucheria  2019-03-20   92           priv->sensor[i].priv = priv;
3e68159d5fdf29 Amit Kucheria  2019-10-16   93           tzd = devm_thermal_zone_of_sensor_register(priv->dev, priv->sensor[i].hw_id,
69b628ac71f07d Amit Kucheria  2019-03-20   94                                                      &priv->sensor[i],
9066073c6c2799 Rajendra Nayak 2016-05-05   95                                                      &tsens_of_ops);
9066073c6c2799 Rajendra Nayak 2016-05-05   96           if (IS_ERR(tzd))
9066073c6c2799 Rajendra Nayak 2016-05-05   97                   continue;
69b628ac71f07d Amit Kucheria  2019-03-20   98           priv->sensor[i].tzd = tzd;
69b628ac71f07d Amit Kucheria  2019-03-20   99           if (priv->ops->enable)
69b628ac71f07d Amit Kucheria  2019-03-20  100                   priv->ops->enable(priv, i);
9066073c6c2799 Rajendra Nayak 2016-05-05  101   }
cd376943ac255b Amit Kucheria  2019-10-16  102
cd376943ac255b Amit Kucheria  2019-10-16 @103   pdev = of_find_device_by_node(priv->dev->of_node);
cd376943ac255b Amit Kucheria  2019-10-16  104   if (!pdev)
cd376943ac255b Amit Kucheria  2019-10-16  105           return -ENODEV;
cd376943ac255b Amit Kucheria  2019-10-16  106
cd376943ac255b Amit Kucheria  2019-10-16  107   irq = platform_get_irq_byname(pdev, "uplow");
cd376943ac255b Amit Kucheria  2019-10-16  108   if (irq < 0) {
cd376943ac255b Amit Kucheria  2019-10-16  109           ret = irq;
cd376943ac255b Amit Kucheria  2019-10-16  110           goto err_put_device;
cd376943ac255b Amit Kucheria  2019-10-16  111   }
cd376943ac255b Amit Kucheria  2019-10-16  112
cd376943ac255b Amit Kucheria  2019-10-16  113   ret = devm_request_threaded_irq(&pdev->dev, irq,
cd376943ac255b Amit Kucheria  2019-10-16  114                                   NULL, tsens_irq_thread,
cd376943ac255b Amit Kucheria  2019-10-16  115                                   IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
cd376943ac255b Amit Kucheria  2019-10-16  116                                   dev_name(&pdev->dev), priv);
cd376943ac255b Amit Kucheria  2019-10-16  117   if (ret) {
cd376943ac255b Amit Kucheria  2019-10-16  118           dev_err(&pdev->dev, "%s: failed to get irq\n", __func__);
cd376943ac255b Amit Kucheria  2019-10-16  119           goto err_put_device;
cd376943ac255b Amit Kucheria  2019-10-16  120   }
cd376943ac255b Amit Kucheria  2019-10-16  121
cd376943ac255b Amit Kucheria  2019-10-16  122   enable_irq_wake(irq);
9066073c6c2799 Rajendra Nayak 2016-05-05 @123   return 0;
cd376943ac255b Amit Kucheria  2019-10-16  124
cd376943ac255b Amit Kucheria  2019-10-16  125  err_put_device:
cd376943ac255b Amit Kucheria  2019-10-16  126   put_device(&pdev->dev);
cd376943ac255b Amit Kucheria  2019-10-16  127   return ret;
9066073c6c2799 Rajendra Nayak 2016-05-05  128  }
9066073c6c2799 Rajendra Nayak 2016-05-05  129

:::::: The code at line 123 was first introduced by commit
:::::: 9066073c6c27994a30187abf3b674770b4088348 thermal: qcom: tsens: Add a skeletal TSENS drivers

Quoted 6 lines

:::::: TO: Rajendra Nayak <[email protected]>
:::::: CC: Zhang Rui <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

From 07fc76e23dc91b2cd1284612ac439b502e977937 Mon Sep 17 00:00:00 2001
Message-Id: <07fc76e23dc91b2cd1284612ac439b502e977937.1571401168.git.amit.kucheria@linaro.org>
From: Amit Kucheria <[email protected]>
Date: Fri, 18 Oct 2019 17:42:54 +0530
Subject: [PATCH] drivers: thermal: tsens: Fixup to call put_device in all
cases

Tweak the code to allow control to fall through to use the same put_device() call for error and success path.

---
 drivers/thermal/qcom/tsens.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/qcom/tsens.c +1 -1
index eeb68dd261b31..5f3db7fe4779b 100644
@@ -120,7 +120,7 @@ static int tsens_register(struct tsens_priv *priv)
 	}
 
 	enable_irq_wake(irq);
-	return 0;
+	ret = 0;
 
 err_put_device:
 	put_device(&pdev->dev);
Signature · 1 line
2.17.1
#2 lore raw
Quoted 7 lines · Amit Kucheria
Quoted 6 lines · Julia Lawall

Hello,

Perhaps pdev should be released or save somewhere before leaving the function.

Quoted 7 lines
Quoted 3 lines

If this is a false positive, I can update the rule.

julia

Thanks for the report, Julia.

I believe the following patch fixes this issue. Can you confirm?

It looks ok to me.

julia

Quoted 96 lines

Daniel, would you like me to respin the series with this fix squashed or will you take this patch on top of thermal-next?

Regards,
Amit

Quoted 88 lines

---------- Forwarded message ----------
Date: Thu, 17 Oct 2019 18:06:41 +0800
From: kbuild test robot <[email protected]>
To: kbuild(a)lists.01.org
Cc: Julia Lawall <[email protected]>
Subject: [daniel.lezcano:thermal/linux-next 11/16]
drivers/thermal/qcom/tsens.c:123:1-7: ERROR: missing put_device; call of_find_device_by_node on line 103,
but without a corresponding object release within this function.

CC: kbuild-all(a)lists.01.org
TO: Amit Kucheria <[email protected]>
CC: Daniel Lezcano <[email protected]>
CC: Stephen Boyd <[email protected]>

tree:   http://git.linaro.org/people/daniel.lezcano/linux thermal/linux-next
head:   124d92b700811381a477ca6b38d1c98417894f0e
commit: cd376943ac255b0b0b299307c12f6bdb28b825a2 [11/16] drivers: thermal: tsens: Add interrupt support

:::::: branch date: 16 hours ago
:::::: commit date: 25 hours ago

If you fix the issue, kindly add following tag

Quoted 1 line
Quoted 1 line

drivers/thermal/qcom/tsens.c:123:1-7: ERROR: missing put_device; call of_find_device_by_node on line 103, but without a corresponding object release within this function.

git remote add daniel.lezcano http://git.linaro.org/people/daniel.lezcano/linux
git remote update daniel.lezcano
git checkout cd376943ac255b0b0b299307c12f6bdb28b825a2
vim +123 drivers/thermal/qcom/tsens.c

9066073c6c2799 Rajendra Nayak 2016-05-05   84
69b628ac71f07d Amit Kucheria  2019-03-20   85  static int tsens_register(struct tsens_priv *priv)
9066073c6c2799 Rajendra Nayak 2016-05-05   86  {
cd376943ac255b Amit Kucheria  2019-10-16   87   int i, ret, irq;
9066073c6c2799 Rajendra Nayak 2016-05-05   88   struct thermal_zone_device *tzd;
cd376943ac255b Amit Kucheria  2019-10-16   89   struct platform_device *pdev;
9066073c6c2799 Rajendra Nayak 2016-05-05   90
69b628ac71f07d Amit Kucheria  2019-03-20   91   for (i = 0;  i < priv->num_sensors; i++) {
69b628ac71f07d Amit Kucheria  2019-03-20   92           priv->sensor[i].priv = priv;
3e68159d5fdf29 Amit Kucheria  2019-10-16   93           tzd = devm_thermal_zone_of_sensor_register(priv->dev, priv->sensor[i].hw_id,
69b628ac71f07d Amit Kucheria  2019-03-20   94                                                      &priv->sensor[i],
9066073c6c2799 Rajendra Nayak 2016-05-05   95                                                      &tsens_of_ops);
9066073c6c2799 Rajendra Nayak 2016-05-05   96           if (IS_ERR(tzd))
9066073c6c2799 Rajendra Nayak 2016-05-05   97                   continue;
69b628ac71f07d Amit Kucheria  2019-03-20   98           priv->sensor[i].tzd = tzd;
69b628ac71f07d Amit Kucheria  2019-03-20   99           if (priv->ops->enable)
69b628ac71f07d Amit Kucheria  2019-03-20  100                   priv->ops->enable(priv, i);
9066073c6c2799 Rajendra Nayak 2016-05-05  101   }
cd376943ac255b Amit Kucheria  2019-10-16  102
cd376943ac255b Amit Kucheria  2019-10-16 @103   pdev = of_find_device_by_node(priv->dev->of_node);
cd376943ac255b Amit Kucheria  2019-10-16  104   if (!pdev)
cd376943ac255b Amit Kucheria  2019-10-16  105           return -ENODEV;
cd376943ac255b Amit Kucheria  2019-10-16  106
cd376943ac255b Amit Kucheria  2019-10-16  107   irq = platform_get_irq_byname(pdev, "uplow");
cd376943ac255b Amit Kucheria  2019-10-16  108   if (irq < 0) {
cd376943ac255b Amit Kucheria  2019-10-16  109           ret = irq;
cd376943ac255b Amit Kucheria  2019-10-16  110           goto err_put_device;
cd376943ac255b Amit Kucheria  2019-10-16  111   }
cd376943ac255b Amit Kucheria  2019-10-16  112
cd376943ac255b Amit Kucheria  2019-10-16  113   ret = devm_request_threaded_irq(&pdev->dev, irq,
cd376943ac255b Amit Kucheria  2019-10-16  114                                   NULL, tsens_irq_thread,
cd376943ac255b Amit Kucheria  2019-10-16  115                                   IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
cd376943ac255b Amit Kucheria  2019-10-16  116                                   dev_name(&pdev->dev), priv);
cd376943ac255b Amit Kucheria  2019-10-16  117   if (ret) {
cd376943ac255b Amit Kucheria  2019-10-16  118           dev_err(&pdev->dev, "%s: failed to get irq\n", __func__);
cd376943ac255b Amit Kucheria  2019-10-16  119           goto err_put_device;
cd376943ac255b Amit Kucheria  2019-10-16  120   }
cd376943ac255b Amit Kucheria  2019-10-16  121
cd376943ac255b Amit Kucheria  2019-10-16  122   enable_irq_wake(irq);
9066073c6c2799 Rajendra Nayak 2016-05-05 @123   return 0;
cd376943ac255b Amit Kucheria  2019-10-16  124
cd376943ac255b Amit Kucheria  2019-10-16  125  err_put_device:
cd376943ac255b Amit Kucheria  2019-10-16  126   put_device(&pdev->dev);
cd376943ac255b Amit Kucheria  2019-10-16  127   return ret;
9066073c6c2799 Rajendra Nayak 2016-05-05  128  }
9066073c6c2799 Rajendra Nayak 2016-05-05  129

:::::: The code at line 123 was first introduced by commit
:::::: 9066073c6c27994a30187abf3b674770b4088348 thermal: qcom: tsens: Add a skeletal TSENS drivers

:::::: TO: Rajendra Nayak <[email protected]>
:::::: CC: Zhang Rui <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw
In reply to Amit Kucheria

Quoting Amit Kucheria (2019-10-18 05:24:03)

Quoted 9 lines · Julia Lawall
Quoted 8 lines

Hello,

Perhaps pdev should be released or save somewhere before leaving the function.

If this is a false positive, I can update the rule.

Quoted 9 lines
Quoted 1 line

julia

Thanks for the report, Julia.

I believe the following patch fixes this issue. Can you confirm?

Daniel, would you like me to respin the series with this fix squashed or will you take this patch on top of thermal-next?

You shouldn't even need the assignment to 0 for ret because it is implicitly equal to 0 at the point in the code.

#4 lore raw
Quoted 15 lines · Stephen Boyd

Quoting Amit Kucheria (2019-10-18 05:24:03)

Quoted 13 lines · Julia Lawall
Quoted 9 lines

Hello,

Perhaps pdev should be released or save somewhere before leaving the function.

If this is a false positive, I can update the rule.

julia

Thanks for the report, Julia.

Quoted 8 lines
Quoted 5 lines

I believe the following patch fixes this issue. Can you confirm?

Daniel, would you like me to respin the series with this fix squashed or will you take this patch on top of thermal-next?

You shouldn't even need the assignment to 0 for ret because it is implicitly equal to 0 at the point in the code.

Indeed. We could get rid of that line completely.