[xlnx:master 227/273] drivers/tty/serial/xilinx_uartps.c:1467:3-9: preceding lock on line 1460 (fwd)

Julia Lawall julia.lawall at inria.fr
Thu Feb 25 16:32:28 EST 2021


Please check whether a mutex_unlock is needed on line 1467.

julia

---------- Forwarded message ----------
Date: Fri, 26 Feb 2021 03:17:23 +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: [xlnx:master 227/273] drivers/tty/serial/xilinx_uartps.c:1467:3-9:
    preceding lock on line 1460

CC: kbuild-all at lists.01.org
CC: linux-arm-kernel at lists.infradead.org
TO: Michal Simek <monstr at monstr.eu>

tree:   https://github.com/Xilinx/linux-xlnx master
head:   f45363ddde384526dafc2b2490763f24c5030e8d
commit: e75553bc99db8983cdfc8c629a5ca741d9897053 [227/273] serial: uartps: Change uart ID port allocation
:::::: branch date: 9 days ago
:::::: commit date: 3 months ago
config: x86_64-randconfig-c002-20210225 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.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>


"coccinelle warnings: (new ones prefixed by >>)"
>> drivers/tty/serial/xilinx_uartps.c:1467:3-9: preceding lock on line 1460

vim +1467 drivers/tty/serial/xilinx_uartps.c

e75553bc99db89 Michal Simek 2018-09-20  1455
e75553bc99db89 Michal Simek 2018-09-20  1456  static int cdns_get_id(struct platform_device *pdev)
e75553bc99db89 Michal Simek 2018-09-20  1457  {
e75553bc99db89 Michal Simek 2018-09-20  1458  	int id, ret;
e75553bc99db89 Michal Simek 2018-09-20  1459
e75553bc99db89 Michal Simek 2018-09-20 @1460  	mutex_lock(&bitmap_lock);
e75553bc99db89 Michal Simek 2018-09-20  1461
e75553bc99db89 Michal Simek 2018-09-20  1462  	/* Alias list is stable that's why get alias bitmap only once */
e75553bc99db89 Michal Simek 2018-09-20  1463  	if (!alias_bitmap_initialized) {
e75553bc99db89 Michal Simek 2018-09-20  1464  		ret = of_alias_get_alias_list(cdns_uart_of_match, "serial",
e75553bc99db89 Michal Simek 2018-09-20  1465  					      alias_bitmap, CDNS_UART_NR_PORTS);
e75553bc99db89 Michal Simek 2018-09-20  1466  		if (ret)
e75553bc99db89 Michal Simek 2018-09-20 @1467  			return ret;
e75553bc99db89 Michal Simek 2018-09-20  1468
e75553bc99db89 Michal Simek 2018-09-20  1469  		alias_bitmap_initialized++;
e75553bc99db89 Michal Simek 2018-09-20  1470  	}
e75553bc99db89 Michal Simek 2018-09-20  1471
e75553bc99db89 Michal Simek 2018-09-20  1472  	/* Make sure that alias ID is not taken by instance without alias */
e75553bc99db89 Michal Simek 2018-09-20  1473  	bitmap_or(bitmap, bitmap, alias_bitmap, CDNS_UART_NR_PORTS);
e75553bc99db89 Michal Simek 2018-09-20  1474
e75553bc99db89 Michal Simek 2018-09-20  1475  	dev_dbg(&pdev->dev, "Alias bitmap: %*pb\n",
e75553bc99db89 Michal Simek 2018-09-20  1476  		CDNS_UART_NR_PORTS, bitmap);
e75553bc99db89 Michal Simek 2018-09-20  1477
e75553bc99db89 Michal Simek 2018-09-20  1478  	/* Look for a serialN alias */
e75553bc99db89 Michal Simek 2018-09-20  1479  	id = of_alias_get_id(pdev->dev.of_node, "serial");
e75553bc99db89 Michal Simek 2018-09-20  1480  	if (id < 0) {
e75553bc99db89 Michal Simek 2018-09-20  1481  		dev_warn(&pdev->dev,
e75553bc99db89 Michal Simek 2018-09-20  1482  			 "No serial alias passed. Using the first free id\n");
e75553bc99db89 Michal Simek 2018-09-20  1483
e75553bc99db89 Michal Simek 2018-09-20  1484  		/*
e75553bc99db89 Michal Simek 2018-09-20  1485  		 * Start with id 0 and check if there is no serial0 alias
e75553bc99db89 Michal Simek 2018-09-20  1486  		 * which points to device which is compatible with this driver.
e75553bc99db89 Michal Simek 2018-09-20  1487  		 * If alias exists then try next free position.
e75553bc99db89 Michal Simek 2018-09-20  1488  		 */
e75553bc99db89 Michal Simek 2018-09-20  1489  		id = 0;
e75553bc99db89 Michal Simek 2018-09-20  1490
e75553bc99db89 Michal Simek 2018-09-20  1491  		for (;;) {
e75553bc99db89 Michal Simek 2018-09-20  1492  			dev_info(&pdev->dev, "Checking id %d\n", id);
e75553bc99db89 Michal Simek 2018-09-20  1493  			id = find_next_zero_bit(bitmap, CDNS_UART_NR_PORTS, id);
e75553bc99db89 Michal Simek 2018-09-20  1494
e75553bc99db89 Michal Simek 2018-09-20  1495  			/* No free empty instance */
e75553bc99db89 Michal Simek 2018-09-20  1496  			if (id == CDNS_UART_NR_PORTS) {
e75553bc99db89 Michal Simek 2018-09-20  1497  				dev_err(&pdev->dev, "No free ID\n");
e75553bc99db89 Michal Simek 2018-09-20  1498  				mutex_unlock(&bitmap_lock);
e75553bc99db89 Michal Simek 2018-09-20  1499  				return -EINVAL;
e75553bc99db89 Michal Simek 2018-09-20  1500  			}
e75553bc99db89 Michal Simek 2018-09-20  1501
e75553bc99db89 Michal Simek 2018-09-20  1502  			dev_dbg(&pdev->dev, "The empty id is %d\n", id);
e75553bc99db89 Michal Simek 2018-09-20  1503  			/* Check if ID is empty */
e75553bc99db89 Michal Simek 2018-09-20  1504  			if (!test_and_set_bit(id, bitmap)) {
e75553bc99db89 Michal Simek 2018-09-20  1505  				/* Break the loop if bit is taken */
e75553bc99db89 Michal Simek 2018-09-20  1506  				dev_dbg(&pdev->dev,
e75553bc99db89 Michal Simek 2018-09-20  1507  					"Selected ID %d allocation passed\n",
e75553bc99db89 Michal Simek 2018-09-20  1508  					id);
e75553bc99db89 Michal Simek 2018-09-20  1509  				break;
e75553bc99db89 Michal Simek 2018-09-20  1510  			}
e75553bc99db89 Michal Simek 2018-09-20  1511  			dev_dbg(&pdev->dev,
e75553bc99db89 Michal Simek 2018-09-20  1512  				"Selected ID %d allocation failed\n", id);
e75553bc99db89 Michal Simek 2018-09-20  1513  			/* if taking bit fails then try next one */
e75553bc99db89 Michal Simek 2018-09-20  1514  			id++;
e75553bc99db89 Michal Simek 2018-09-20  1515  		}
e75553bc99db89 Michal Simek 2018-09-20  1516  	}
e75553bc99db89 Michal Simek 2018-09-20  1517
e75553bc99db89 Michal Simek 2018-09-20  1518  	mutex_unlock(&bitmap_lock);
e75553bc99db89 Michal Simek 2018-09-20  1519
e75553bc99db89 Michal Simek 2018-09-20  1520  	return id;
e75553bc99db89 Michal Simek 2018-09-20  1521  }
e75553bc99db89 Michal Simek 2018-09-20  1522

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 25913 bytes
Desc: 
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20210225/bace290c/attachment-0001.gz>


More information about the linux-arm-kernel mailing list