[xilinx-xlnx:xlnx_rebase_v5.15 304/872] serial: uartps: preceding lock on line 1458
Julia Lawall
julia.lawall at inria.fr
Tue Feb 8 12:55:05 PST 2022
The return on line 1465 is missing a mutex_unlock on &bitmap_lock.
julia
---------- Forwarded message ----------
Date: Tue, 8 Feb 2022 18:55:12 +0800
From: kernel test robot <lkp at intel.com>
To: kbuild at lists.01.org
Cc: lkp at intel.com, Julia Lawall <julia.lawall at lip6.fr>
Subject: [xilinx-xlnx:xlnx_rebase_v5.15 304/872]
drivers/tty/serial/xilinx_uartps.c:1465:3-9: preceding lock on line 1458
CC: kbuild-all at lists.01.org
CC: linux-arm-kernel at lists.infradead.org
TO: Michal Simek <monstr at monstr.eu>
CC: Shubhrajyoti Datta <shubhrajyoti.datta at xilinx.com>
CC: Radhey Shyam Pandey <radhey.shyam.pandey at xilinx.com>
tree: https://github.com/Xilinx/linux-xlnx xlnx_rebase_v5.15
head: 1183ce490adb103e5e569b8ebd74c50c885ddc05
commit: f0090478ae8a76b733a846f50dc5559fff3c461f [304/872] serial: uartps: Change uart ID port allocation
:::::: branch date: 7 days ago
:::::: commit date: 8 days ago
config: xtensa-randconfig-c004-20220207 (https://download.01.org/0day-ci/archive/20220208/202202081830.Tk4vrixD-lkp@intel.com/config)
compiler: xtensa-linux-gcc (GCC) 11.2.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp at intel.com>
Reported-by: Julia Lawall <julia.lawall at lip6.fr>
cocci warnings: (new ones prefixed by >>)
>> drivers/tty/serial/xilinx_uartps.c:1465:3-9: preceding lock on line 1458
vim +1465 drivers/tty/serial/xilinx_uartps.c
f0090478ae8a76 Michal Simek 2018-09-20 1453
f0090478ae8a76 Michal Simek 2018-09-20 1454 static int cdns_get_id(struct platform_device *pdev)
f0090478ae8a76 Michal Simek 2018-09-20 1455 {
f0090478ae8a76 Michal Simek 2018-09-20 1456 int id, ret;
f0090478ae8a76 Michal Simek 2018-09-20 1457
f0090478ae8a76 Michal Simek 2018-09-20 @1458 mutex_lock(&bitmap_lock);
f0090478ae8a76 Michal Simek 2018-09-20 1459
f0090478ae8a76 Michal Simek 2018-09-20 1460 /* Alias list is stable that's why get alias bitmap only once */
f0090478ae8a76 Michal Simek 2018-09-20 1461 if (!alias_bitmap_initialized) {
f0090478ae8a76 Michal Simek 2018-09-20 1462 ret = of_alias_get_alias_list(cdns_uart_of_match, "serial",
f0090478ae8a76 Michal Simek 2018-09-20 1463 alias_bitmap, CDNS_UART_NR_PORTS);
f0090478ae8a76 Michal Simek 2018-09-20 1464 if (ret)
f0090478ae8a76 Michal Simek 2018-09-20 @1465 return ret;
f0090478ae8a76 Michal Simek 2018-09-20 1466
f0090478ae8a76 Michal Simek 2018-09-20 1467 alias_bitmap_initialized++;
f0090478ae8a76 Michal Simek 2018-09-20 1468 }
f0090478ae8a76 Michal Simek 2018-09-20 1469
f0090478ae8a76 Michal Simek 2018-09-20 1470 /* Make sure that alias ID is not taken by instance without alias */
f0090478ae8a76 Michal Simek 2018-09-20 1471 bitmap_or(bitmap, bitmap, alias_bitmap, CDNS_UART_NR_PORTS);
f0090478ae8a76 Michal Simek 2018-09-20 1472
f0090478ae8a76 Michal Simek 2018-09-20 1473 dev_dbg(&pdev->dev, "Alias bitmap: %*pb\n",
f0090478ae8a76 Michal Simek 2018-09-20 1474 CDNS_UART_NR_PORTS, bitmap);
f0090478ae8a76 Michal Simek 2018-09-20 1475
f0090478ae8a76 Michal Simek 2018-09-20 1476 /* Look for a serialN alias */
f0090478ae8a76 Michal Simek 2018-09-20 1477 id = of_alias_get_id(pdev->dev.of_node, "serial");
f0090478ae8a76 Michal Simek 2018-09-20 1478 if (id < 0) {
f0090478ae8a76 Michal Simek 2018-09-20 1479 dev_warn(&pdev->dev,
f0090478ae8a76 Michal Simek 2018-09-20 1480 "No serial alias passed. Using the first free id\n");
f0090478ae8a76 Michal Simek 2018-09-20 1481
f0090478ae8a76 Michal Simek 2018-09-20 1482 /*
f0090478ae8a76 Michal Simek 2018-09-20 1483 * Start with id 0 and check if there is no serial0 alias
f0090478ae8a76 Michal Simek 2018-09-20 1484 * which points to device which is compatible with this driver.
f0090478ae8a76 Michal Simek 2018-09-20 1485 * If alias exists then try next free position.
f0090478ae8a76 Michal Simek 2018-09-20 1486 */
f0090478ae8a76 Michal Simek 2018-09-20 1487 id = 0;
f0090478ae8a76 Michal Simek 2018-09-20 1488
f0090478ae8a76 Michal Simek 2018-09-20 1489 for (;;) {
f0090478ae8a76 Michal Simek 2018-09-20 1490 dev_info(&pdev->dev, "Checking id %d\n", id);
f0090478ae8a76 Michal Simek 2018-09-20 1491 id = find_next_zero_bit(bitmap, CDNS_UART_NR_PORTS, id);
f0090478ae8a76 Michal Simek 2018-09-20 1492
f0090478ae8a76 Michal Simek 2018-09-20 1493 /* No free empty instance */
f0090478ae8a76 Michal Simek 2018-09-20 1494 if (id == CDNS_UART_NR_PORTS) {
f0090478ae8a76 Michal Simek 2018-09-20 1495 dev_err(&pdev->dev, "No free ID\n");
f0090478ae8a76 Michal Simek 2018-09-20 1496 mutex_unlock(&bitmap_lock);
f0090478ae8a76 Michal Simek 2018-09-20 1497 return -EINVAL;
f0090478ae8a76 Michal Simek 2018-09-20 1498 }
f0090478ae8a76 Michal Simek 2018-09-20 1499
f0090478ae8a76 Michal Simek 2018-09-20 1500 dev_dbg(&pdev->dev, "The empty id is %d\n", id);
f0090478ae8a76 Michal Simek 2018-09-20 1501 /* Check if ID is empty */
f0090478ae8a76 Michal Simek 2018-09-20 1502 if (!test_and_set_bit(id, bitmap)) {
f0090478ae8a76 Michal Simek 2018-09-20 1503 /* Break the loop if bit is taken */
f0090478ae8a76 Michal Simek 2018-09-20 1504 dev_dbg(&pdev->dev,
f0090478ae8a76 Michal Simek 2018-09-20 1505 "Selected ID %d allocation passed\n",
f0090478ae8a76 Michal Simek 2018-09-20 1506 id);
f0090478ae8a76 Michal Simek 2018-09-20 1507 break;
f0090478ae8a76 Michal Simek 2018-09-20 1508 }
f0090478ae8a76 Michal Simek 2018-09-20 1509 dev_dbg(&pdev->dev,
f0090478ae8a76 Michal Simek 2018-09-20 1510 "Selected ID %d allocation failed\n", id);
f0090478ae8a76 Michal Simek 2018-09-20 1511 /* if taking bit fails then try next one */
f0090478ae8a76 Michal Simek 2018-09-20 1512 id++;
f0090478ae8a76 Michal Simek 2018-09-20 1513 }
f0090478ae8a76 Michal Simek 2018-09-20 1514 }
f0090478ae8a76 Michal Simek 2018-09-20 1515
f0090478ae8a76 Michal Simek 2018-09-20 1516 mutex_unlock(&bitmap_lock);
f0090478ae8a76 Michal Simek 2018-09-20 1517
f0090478ae8a76 Michal Simek 2018-09-20 1518 return id;
f0090478ae8a76 Michal Simek 2018-09-20 1519 }
f0090478ae8a76 Michal Simek 2018-09-20 1520
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
More information about the linux-arm-kernel
mailing list