diff mbox series

[-next] drivers: thermal: tsens: fix missing put_device error

Message ID 20200925091532.1855861-1-zhengbin13@huawei.com (mailing list archive)
State New, archived
Delegated to: Daniel Lezcano
Headers show
Series [-next] drivers: thermal: tsens: fix missing put_device error | expand

Commit Message

Zheng Bin Sept. 25, 2020, 9:15 a.m. UTC
Fixes coccicheck error:

drivers/thermal/qcom/tsens.c:759:4-10: ERROR: missing put_device; call of_find_device_by_node on line 715, but without a corresponding object release within this function.

Fixes: a7ff82976122 ("drivers: thermal: tsens: Merge tsens-common.c into tsens.c")
Signed-off-by: Zheng Bin <zhengbin13@huawei.com>
---
 drivers/thermal/qcom/tsens.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--
2.25.4

Comments

kernel test robot Sept. 25, 2020, 12:24 p.m. UTC | #1
Hi Zheng,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20200924]

url:    https://github.com/0day-ci/linux/commits/Zheng-Bin/drivers-thermal-tsens-fix-missing-put_device-error/20200925-171533
base:    d1d2220c7f39d0fca302c4ba6cca4ede01660a2b
config: mips-allyesconfig (attached as .config)
compiler: mips-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/25ca3b91e2e59330feedab4f71ad2aef593bdbb1
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Zheng-Bin/drivers-thermal-tsens-fix-missing-put_device-error/20200925-171533
        git checkout 25ca3b91e2e59330feedab4f71ad2aef593bdbb1
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/thermal/qcom/tsens.c: In function 'init_common':
>> drivers/thermal/qcom/tsens.c:759:5: error: 'err' undeclared (first use in this function)
     759 |     err = PTR_ERR(priv->rf[i]);
         |     ^~~
   drivers/thermal/qcom/tsens.c:759:5: note: each undeclared identifier is reported only once for each function it appears in

vim +/err +759 drivers/thermal/qcom/tsens.c

   706	
   707	int __init init_common(struct tsens_priv *priv)
   708	{
   709		void __iomem *tm_base, *srot_base;
   710		struct device *dev = priv->dev;
   711		u32 ver_minor;
   712		struct resource *res;
   713		u32 enabled;
   714		int ret, i, j;
   715		struct platform_device *op = of_find_device_by_node(priv->dev->of_node);
   716	
   717		if (!op)
   718			return -EINVAL;
   719	
   720		if (op->num_resources > 1) {
   721			/* DT with separate SROT and TM address space */
   722			priv->tm_offset = 0;
   723			res = platform_get_resource(op, IORESOURCE_MEM, 1);
   724			srot_base = devm_ioremap_resource(dev, res);
   725			if (IS_ERR(srot_base)) {
   726				ret = PTR_ERR(srot_base);
   727				goto err_put_device;
   728			}
   729	
   730			priv->srot_map = devm_regmap_init_mmio(dev, srot_base,
   731							       &tsens_srot_config);
   732			if (IS_ERR(priv->srot_map)) {
   733				ret = PTR_ERR(priv->srot_map);
   734				goto err_put_device;
   735			}
   736		} else {
   737			/* old DTs where SROT and TM were in a contiguous 2K block */
   738			priv->tm_offset = 0x1000;
   739		}
   740	
   741		res = platform_get_resource(op, IORESOURCE_MEM, 0);
   742		tm_base = devm_ioremap_resource(dev, res);
   743		if (IS_ERR(tm_base)) {
   744			ret = PTR_ERR(tm_base);
   745			goto err_put_device;
   746		}
   747	
   748		priv->tm_map = devm_regmap_init_mmio(dev, tm_base, &tsens_config);
   749		if (IS_ERR(priv->tm_map)) {
   750			ret = PTR_ERR(priv->tm_map);
   751			goto err_put_device;
   752		}
   753	
   754		if (tsens_version(priv) > VER_0_1) {
   755			for (i = VER_MAJOR; i <= VER_STEP; i++) {
   756				priv->rf[i] = devm_regmap_field_alloc(dev, priv->srot_map,
   757								      priv->fields[i]);
   758				if (IS_ERR(priv->rf[i])) {
 > 759					err = PTR_ERR(priv->rf[i]);
   760					goto err_put_device;
   761				}
   762			}
   763			ret = regmap_field_read(priv->rf[VER_MINOR], &ver_minor);
   764			if (ret)
   765				goto err_put_device;
   766		}
   767	
   768		priv->rf[TSENS_EN] = devm_regmap_field_alloc(dev, priv->srot_map,
   769							     priv->fields[TSENS_EN]);
   770		if (IS_ERR(priv->rf[TSENS_EN])) {
   771			ret = PTR_ERR(priv->rf[TSENS_EN]);
   772			goto err_put_device;
   773		}
   774		ret = regmap_field_read(priv->rf[TSENS_EN], &enabled);
   775		if (ret)
   776			goto err_put_device;
   777		if (!enabled) {
   778			dev_err(dev, "%s: device not enabled\n", __func__);
   779			ret = -ENODEV;
   780			goto err_put_device;
   781		}
   782	
   783		priv->rf[SENSOR_EN] = devm_regmap_field_alloc(dev, priv->srot_map,
   784							      priv->fields[SENSOR_EN]);
   785		if (IS_ERR(priv->rf[SENSOR_EN])) {
   786			ret = PTR_ERR(priv->rf[SENSOR_EN]);
   787			goto err_put_device;
   788		}
   789		priv->rf[INT_EN] = devm_regmap_field_alloc(dev, priv->tm_map,
   790							   priv->fields[INT_EN]);
   791		if (IS_ERR(priv->rf[INT_EN])) {
   792			ret = PTR_ERR(priv->rf[INT_EN]);
   793			goto err_put_device;
   794		}
   795	
   796		/* This loop might need changes if enum regfield_ids is reordered */
   797		for (j = LAST_TEMP_0; j <= UP_THRESH_15; j += 16) {
   798			for (i = 0; i < priv->feat->max_sensors; i++) {
   799				int idx = j + i;
   800	
   801				priv->rf[idx] = devm_regmap_field_alloc(dev,
   802									priv->tm_map,
   803									priv->fields[idx]);
   804				if (IS_ERR(priv->rf[idx])) {
   805					ret = PTR_ERR(priv->rf[idx]);
   806					goto err_put_device;
   807				}
   808			}
   809		}
   810	
   811		if (priv->feat->crit_int) {
   812			/* Loop might need changes if enum regfield_ids is reordered */
   813			for (j = CRITICAL_STATUS_0; j <= CRIT_THRESH_15; j += 16) {
   814				for (i = 0; i < priv->feat->max_sensors; i++) {
   815					int idx = j + i;
   816	
   817					priv->rf[idx] =
   818						devm_regmap_field_alloc(dev,
   819									priv->tm_map,
   820									priv->fields[idx]);
   821					if (IS_ERR(priv->rf[idx])) {
   822						ret = PTR_ERR(priv->rf[idx]);
   823						goto err_put_device;
   824					}
   825				}
   826			}
   827		}
   828	
   829		if (tsens_version(priv) > VER_1_X &&  ver_minor > 2) {
   830			/* Watchdog is present only on v2.3+ */
   831			priv->feat->has_watchdog = 1;
   832			for (i = WDOG_BARK_STATUS; i <= CC_MON_MASK; i++) {
   833				priv->rf[i] = devm_regmap_field_alloc(dev, priv->tm_map,
   834								      priv->fields[i]);
   835				if (IS_ERR(priv->rf[i])) {
   836					ret = PTR_ERR(priv->rf[i]);
   837					goto err_put_device;
   838				}
   839			}
   840			/*
   841			 * Watchdog is already enabled, unmask the bark.
   842			 * Disable cycle completion monitoring
   843			 */
   844			regmap_field_write(priv->rf[WDOG_BARK_MASK], 0);
   845			regmap_field_write(priv->rf[CC_MON_MASK], 1);
   846		}
   847	
   848		spin_lock_init(&priv->ul_lock);
   849		tsens_enable_irq(priv);
   850		tsens_debug_init(op);
   851	
   852	err_put_device:
   853		put_device(&op->dev);
   854		return ret;
   855	}
   856	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index d8ce3a687b80..0267771e7f52 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -755,8 +755,10 @@  int __init init_common(struct tsens_priv *priv)
 		for (i = VER_MAJOR; i <= VER_STEP; i++) {
 			priv->rf[i] = devm_regmap_field_alloc(dev, priv->srot_map,
 							      priv->fields[i]);
-			if (IS_ERR(priv->rf[i]))
-				return PTR_ERR(priv->rf[i]);
+			if (IS_ERR(priv->rf[i])) {
+				err = PTR_ERR(priv->rf[i]);
+				goto err_put_device;
+			}
 		}
 		ret = regmap_field_read(priv->rf[VER_MINOR], &ver_minor);
 		if (ret)