Re: [PATCH] media: bdisp: fix reference count leaks due to pm_runtime_get_sync

From: kernel test robot
Date: Sun Jun 14 2020 - 03:10:51 EST


Hi Aditya,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v5.7 next-20200614]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url: https://github.com/0day-ci/linux/commits/Aditya-Pakki/media-bdisp-fix-reference-count-leaks-due-to-pm_runtime_get_sync/20200614-115114
base: git://linuxtv.org/media_tree.git master
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project cb5072d1877b38c972f95092db2cedbcddb81da6)
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
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64

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

All warnings (new ones prefixed by >>, old ones prefixed by <<):

>> drivers/media/platform/sti/bdisp/bdisp-v4l2.c:1403:1: warning: unused label 'err_dbg' [-Wunused-label]
err_dbg:
^~~~~~~~
1 warning generated.

vim +/err_dbg +1403 drivers/media/platform/sti/bdisp/bdisp-v4l2.c

28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1284
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1285 static int bdisp_probe(struct platform_device *pdev)
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1286 {
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1287 struct bdisp_dev *bdisp;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1288 struct resource *res;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1289 struct device *dev = &pdev->dev;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1290 int ret;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1291
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1292 dev_dbg(dev, "%s\n", __func__);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1293
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1294 bdisp = devm_kzalloc(dev, sizeof(struct bdisp_dev), GFP_KERNEL);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1295 if (!bdisp)
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1296 return -ENOMEM;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1297
2732bb765f14eb Fabien Dessenne 2018-05-15 1298 ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
2732bb765f14eb Fabien Dessenne 2018-05-15 1299 if (ret)
2732bb765f14eb Fabien Dessenne 2018-05-15 1300 return ret;
2732bb765f14eb Fabien Dessenne 2018-05-15 1301
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1302 bdisp->pdev = pdev;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1303 bdisp->dev = dev;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1304 platform_set_drvdata(pdev, bdisp);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1305
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1306 if (dev->of_node)
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1307 bdisp->id = of_alias_get_id(pdev->dev.of_node, BDISP_NAME);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1308 else
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1309 bdisp->id = pdev->id;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1310
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1311 init_waitqueue_head(&bdisp->irq_queue);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1312 INIT_DELAYED_WORK(&bdisp->timeout_work, bdisp_irq_timeout);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1313 bdisp->work_queue = create_workqueue(BDISP_NAME);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1314
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1315 spin_lock_init(&bdisp->slock);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1316 mutex_init(&bdisp->lock);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1317
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1318 /* get resources */
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1319 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1320 bdisp->regs = devm_ioremap_resource(dev, res);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1321 if (IS_ERR(bdisp->regs)) {
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1322 dev_err(dev, "failed to get regs\n");
8ea1c5af489a76 Chuhong Yuan 2019-11-13 1323 ret = PTR_ERR(bdisp->regs);
8ea1c5af489a76 Chuhong Yuan 2019-11-13 1324 goto err_wq;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1325 }
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1326
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1327 bdisp->clock = devm_clk_get(dev, BDISP_NAME);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1328 if (IS_ERR(bdisp->clock)) {
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1329 dev_err(dev, "failed to get clock\n");
8ea1c5af489a76 Chuhong Yuan 2019-11-13 1330 ret = PTR_ERR(bdisp->clock);
8ea1c5af489a76 Chuhong Yuan 2019-11-13 1331 goto err_wq;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1332 }
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1333
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1334 ret = clk_prepare(bdisp->clock);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1335 if (ret < 0) {
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1336 dev_err(dev, "clock prepare failed\n");
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1337 bdisp->clock = ERR_PTR(-EINVAL);
8ea1c5af489a76 Chuhong Yuan 2019-11-13 1338 goto err_wq;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1339 }
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1340
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1341 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1342 if (!res) {
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1343 dev_err(dev, "failed to get IRQ resource\n");
017f4fb7f2eaa1 Wei Yongjun 2016-09-21 1344 ret = -EINVAL;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1345 goto err_clk;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1346 }
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1347
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1348 ret = devm_request_threaded_irq(dev, res->start, bdisp_irq_handler,
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1349 bdisp_irq_thread, IRQF_ONESHOT,
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1350 pdev->name, bdisp);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1351 if (ret) {
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1352 dev_err(dev, "failed to install irq\n");
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1353 goto err_clk;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1354 }
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1355
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1356 /* v4l2 register */
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1357 ret = v4l2_device_register(dev, &bdisp->v4l2_dev);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1358 if (ret) {
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1359 dev_err(dev, "failed to register\n");
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1360 goto err_clk;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1361 }
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1362
34b6beb65beb7f Fabien Dessenne 2015-05-12 1363 /* Debug */
34b6beb65beb7f Fabien Dessenne 2015-05-12 1364 ret = bdisp_debugfs_create(bdisp);
34b6beb65beb7f Fabien Dessenne 2015-05-12 1365 if (ret) {
34b6beb65beb7f Fabien Dessenne 2015-05-12 1366 dev_err(dev, "failed to create debugfs\n");
34b6beb65beb7f Fabien Dessenne 2015-05-12 1367 goto err_v4l2;
34b6beb65beb7f Fabien Dessenne 2015-05-12 1368 }
34b6beb65beb7f Fabien Dessenne 2015-05-12 1369
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1370 /* Power management */
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1371 pm_runtime_enable(dev);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1372 ret = pm_runtime_get_sync(dev);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1373 if (ret < 0) {
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1374 dev_err(dev, "failed to set PM\n");
00406f27b7445c Aditya Pakki 2020-06-13 1375 goto err_pm;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1376 }
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1377
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1378 /* Filters */
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1379 if (bdisp_hw_alloc_filters(bdisp->dev)) {
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1380 dev_err(bdisp->dev, "no memory for filters\n");
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1381 ret = -ENOMEM;
dce57314b53760 Hans Verkuil 2016-02-15 1382 goto err_pm;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1383 }
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1384
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1385 /* Register */
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1386 ret = bdisp_register_device(bdisp);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1387 if (ret) {
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1388 dev_err(dev, "failed to register\n");
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1389 goto err_filter;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1390 }
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1391
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1392 dev_info(dev, "%s%d registered as /dev/video%d\n", BDISP_NAME,
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1393 bdisp->id, bdisp->vdev.num);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1394
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1395 pm_runtime_put(dev);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1396
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1397 return 0;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1398
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1399 err_filter:
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1400 bdisp_hw_free_filters(bdisp->dev);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1401 err_pm:
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1402 pm_runtime_put(dev);
34b6beb65beb7f Fabien Dessenne 2015-05-12 @1403 err_dbg:
34b6beb65beb7f Fabien Dessenne 2015-05-12 1404 bdisp_debugfs_remove(bdisp);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1405 err_v4l2:
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1406 v4l2_device_unregister(&bdisp->v4l2_dev);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1407 err_clk:
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1408 if (!IS_ERR(bdisp->clock))
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1409 clk_unprepare(bdisp->clock);
8ea1c5af489a76 Chuhong Yuan 2019-11-13 1410 err_wq:
8ea1c5af489a76 Chuhong Yuan 2019-11-13 1411 destroy_workqueue(bdisp->work_queue);
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1412 return ret;
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1413 }
28ffeebbb7bdc0 Fabien Dessenne 2015-05-12 1414

:::::: The code at line 1403 was first introduced by commit
:::::: 34b6beb65beb7f7726baa771661c671310445265 [media] bdisp: add debug file system

:::::: TO: Fabien Dessenne <fabien.dessenne@xxxxxx>
:::::: CC: Mauro Carvalho Chehab <mchehab@xxxxxxxxxxxxxxx>

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

Attachment: .config.gz
Description: application/gzip