CC: kbuild-...@lists.01.org
CC: linux-ker...@vger.kernel.org
TO: Bernard Metzler <b...@zurich.ibm.com>
CC: Jason Gunthorpe <j...@mellanox.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   42f82040ee66db13525dc6f14b8559890b2f4c1c
commit: 33fb27fd54465c74cbffba6315b2f043e90cec4c RDMA/siw: Fix passive 
connection establishment
date:   4 months ago
:::::: branch date: 18 hours ago
:::::: commit date: 4 months ago
config: riscv-randconfig-m031-20200710 (attached as .config)
compiler: riscv64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <l...@intel.com>
Reported-by: Dan Carpenter <dan.carpen...@oracle.com>

New smatch warnings:
drivers/infiniband/sw/siw/siw_cm.c:1898 siw_create_listen() error: double 
unlocked 'cep->lock' (orig line 1888)

Old smatch warnings:
drivers/infiniband/sw/siw/siw_cm.c:435 siw_qp_cm_drop() error: double unlocked 
'cep->lock' (orig line 385)
drivers/infiniband/sw/siw/siw_cm.c:979 siw_accept_newconn() error: double 
unlocked 'new_cep->lock' (orig line 977)
drivers/infiniband/sw/siw/siw_cm.c:997 siw_accept_newconn() error: we 
previously assumed 'new_cep' could be null (see line 991)
drivers/infiniband/sw/siw/siw_cm.c:1033 siw_cm_work_handler() error: double 
unlocked 'cep->listen_cep->lock' (orig line 1025)
drivers/infiniband/sw/siw/siw_cm.c:1162 siw_cm_work_handler() error: double 
unlocked 'cep->lock' (orig line 1015)
drivers/infiniband/sw/siw/siw_cm.c:1167 siw_cm_work_handler() error: double 
unlocked 'cep->lock' (orig line 1162)
drivers/infiniband/sw/siw/siw_cm.c:1182 siw_cm_work_handler() error: double 
unlocked 'cep->lock' (orig line 1015)
drivers/infiniband/sw/siw/siw_cm.c:1496 siw_connect() error: double unlocked 
'cep->lock' (orig line 1407)
drivers/infiniband/sw/siw/siw_cm.c:1519 siw_connect() error: double unlocked 
'cep->lock' (orig line 1407)
drivers/infiniband/sw/siw/siw_cm.c:1569 siw_accept() error: double unlocked 
'cep->lock' (orig line 1555)
drivers/infiniband/sw/siw/siw_cm.c:1577 siw_accept() error: double unlocked 
'cep->lock' (orig line 1555)
drivers/infiniband/sw/siw/siw_cm.c:1703 siw_accept() error: double unlocked 
'cep->lock' (orig line 1555)
drivers/infiniband/sw/siw/siw_cm.c:1724 siw_accept() error: double unlocked 
'cep->lock' (orig line 1555)
drivers/infiniband/sw/siw/siw_cm.c:1748 siw_reject() error: double unlocked 
'cep->lock' (orig line 1740)
drivers/infiniband/sw/siw/siw_cm.c:1766 siw_reject() error: double unlocked 
'cep->lock' (orig line 1740)
drivers/infiniband/sw/siw/siw_cm.c:1933 siw_drop_listeners() error: double 
unlocked 'cep->lock' (orig line 1921)

# 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=33fb27fd54465c74cbffba6315b2f043e90cec4c
git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git remote update linus
git checkout 33fb27fd54465c74cbffba6315b2f043e90cec4c
vim +1898 drivers/infiniband/sw/siw/siw_cm.c

6c52fdc244b5cc Bernard Metzler 2019-06-20  1771  
33fb27fd54465c Bernard Metzler 2020-02-28  1772  /*
33fb27fd54465c Bernard Metzler 2020-02-28  1773   * siw_create_listen - Create 
resources for a listener's IWCM ID @id
33fb27fd54465c Bernard Metzler 2020-02-28  1774   *
33fb27fd54465c Bernard Metzler 2020-02-28  1775   * Starts listen on the socket 
address id->local_addr.
33fb27fd54465c Bernard Metzler 2020-02-28  1776   *
33fb27fd54465c Bernard Metzler 2020-02-28  1777   */
33fb27fd54465c Bernard Metzler 2020-02-28  1778  int siw_create_listen(struct 
iw_cm_id *id, int backlog)
6c52fdc244b5cc Bernard Metzler 2019-06-20  1779  {
6c52fdc244b5cc Bernard Metzler 2019-06-20  1780         struct socket *s;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1781         struct siw_cep *cep = 
NULL;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1782         struct siw_device *sdev 
= to_siw_dev(id->device);
33fb27fd54465c Bernard Metzler 2020-02-28  1783         int addr_family = 
id->local_addr.ss_family;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1784         int rv = 0, s_val;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1785  
33fb27fd54465c Bernard Metzler 2020-02-28  1786         if (addr_family != 
AF_INET && addr_family != AF_INET6)
33fb27fd54465c Bernard Metzler 2020-02-28  1787                 return 
-EAFNOSUPPORT;
33fb27fd54465c Bernard Metzler 2020-02-28  1788  
6c52fdc244b5cc Bernard Metzler 2019-06-20  1789         rv = 
sock_create(addr_family, SOCK_STREAM, IPPROTO_TCP, &s);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1790         if (rv < 0)
6c52fdc244b5cc Bernard Metzler 2019-06-20  1791                 return rv;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1792  
6c52fdc244b5cc Bernard Metzler 2019-06-20  1793         /*
6c52fdc244b5cc Bernard Metzler 2019-06-20  1794          * Allow binding local 
port when still in TIME_WAIT from last close.
6c52fdc244b5cc Bernard Metzler 2019-06-20  1795          */
6c52fdc244b5cc Bernard Metzler 2019-06-20  1796         s_val = 1;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1797         rv = 
kernel_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&s_val,
6c52fdc244b5cc Bernard Metzler 2019-06-20  1798                                
sizeof(s_val));
6c52fdc244b5cc Bernard Metzler 2019-06-20  1799         if (rv) {
c536277e0db1ad Bernard Metzler 2019-08-22  1800                 
siw_dbg(id->device, "setsockopt error: %d\n", rv);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1801                 goto error;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1802         }
33fb27fd54465c Bernard Metzler 2020-02-28  1803         if (addr_family == 
AF_INET) {
33fb27fd54465c Bernard Metzler 2020-02-28  1804                 struct 
sockaddr_in *laddr = &to_sockaddr_in(id->local_addr);
33fb27fd54465c Bernard Metzler 2020-02-28  1805  
33fb27fd54465c Bernard Metzler 2020-02-28  1806                 /* For wildcard 
addr, limit binding to current device only */
33fb27fd54465c Bernard Metzler 2020-02-28  1807                 if 
(ipv4_is_zeronet(laddr->sin_addr.s_addr))
33fb27fd54465c Bernard Metzler 2020-02-28  1808                         
s->sk->sk_bound_dev_if = sdev->netdev->ifindex;
33fb27fd54465c Bernard Metzler 2020-02-28  1809  
33fb27fd54465c Bernard Metzler 2020-02-28  1810                 rv = 
s->ops->bind(s, (struct sockaddr *)laddr,
33fb27fd54465c Bernard Metzler 2020-02-28  1811                                 
  sizeof(struct sockaddr_in));
33fb27fd54465c Bernard Metzler 2020-02-28  1812         } else {
33fb27fd54465c Bernard Metzler 2020-02-28  1813                 struct 
sockaddr_in6 *laddr = &to_sockaddr_in6(id->local_addr);
33fb27fd54465c Bernard Metzler 2020-02-28  1814  
33fb27fd54465c Bernard Metzler 2020-02-28  1815                 /* For wildcard 
addr, limit binding to current device only */
33fb27fd54465c Bernard Metzler 2020-02-28  1816                 if 
(ipv6_addr_any(&laddr->sin6_addr))
33fb27fd54465c Bernard Metzler 2020-02-28  1817                         
s->sk->sk_bound_dev_if = sdev->netdev->ifindex;
33fb27fd54465c Bernard Metzler 2020-02-28  1818  
33fb27fd54465c Bernard Metzler 2020-02-28  1819                 rv = 
s->ops->bind(s, (struct sockaddr *)laddr,
6c52fdc244b5cc Bernard Metzler 2019-06-20  1820                                 
  sizeof(struct sockaddr_in6));
33fb27fd54465c Bernard Metzler 2020-02-28  1821         }
6c52fdc244b5cc Bernard Metzler 2019-06-20  1822         if (rv) {
c536277e0db1ad Bernard Metzler 2019-08-22  1823                 
siw_dbg(id->device, "socket bind error: %d\n", rv);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1824                 goto error;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1825         }
6c52fdc244b5cc Bernard Metzler 2019-06-20  1826         cep = 
siw_cep_alloc(sdev);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1827         if (!cep) {
6c52fdc244b5cc Bernard Metzler 2019-06-20  1828                 rv = -ENOMEM;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1829                 goto error;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1830         }
6c52fdc244b5cc Bernard Metzler 2019-06-20  1831         
siw_cep_socket_assoc(cep, s);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1832  
6c52fdc244b5cc Bernard Metzler 2019-06-20  1833         rv = 
siw_cm_alloc_work(cep, backlog);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1834         if (rv) {
6c52fdc244b5cc Bernard Metzler 2019-06-20  1835                 
siw_dbg(id->device,
c536277e0db1ad Bernard Metzler 2019-08-22  1836                         
"alloc_work error %d, backlog %d\n",
6c52fdc244b5cc Bernard Metzler 2019-06-20  1837                         rv, 
backlog);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1838                 goto error;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1839         }
6c52fdc244b5cc Bernard Metzler 2019-06-20  1840         rv = s->ops->listen(s, 
backlog);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1841         if (rv) {
c536277e0db1ad Bernard Metzler 2019-08-22  1842                 
siw_dbg(id->device, "listen error %d\n", rv);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1843                 goto error;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1844         }
6c52fdc244b5cc Bernard Metzler 2019-06-20  1845         cep->cm_id = id;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1846         id->add_ref(id);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1847  
6c52fdc244b5cc Bernard Metzler 2019-06-20  1848         /*
6c52fdc244b5cc Bernard Metzler 2019-06-20  1849          * In case of a 
wildcard rdma_listen on a multi-homed device,
6c52fdc244b5cc Bernard Metzler 2019-06-20  1850          * a listener's IWCM id 
is associated with more than one listening CEP.
6c52fdc244b5cc Bernard Metzler 2019-06-20  1851          *
6c52fdc244b5cc Bernard Metzler 2019-06-20  1852          * We currently use 
id->provider_data in three different ways:
6c52fdc244b5cc Bernard Metzler 2019-06-20  1853          *
6c52fdc244b5cc Bernard Metzler 2019-06-20  1854          * o For a listener's 
IWCM id, id->provider_data points to
6c52fdc244b5cc Bernard Metzler 2019-06-20  1855          *   the list_head of 
the list of listening CEPs.
6c52fdc244b5cc Bernard Metzler 2019-06-20  1856          *   Uses: 
siw_create_listen(), siw_destroy_listen()
6c52fdc244b5cc Bernard Metzler 2019-06-20  1857          *
6c52fdc244b5cc Bernard Metzler 2019-06-20  1858          * o For each accepted 
passive-side IWCM id, id->provider_data
6c52fdc244b5cc Bernard Metzler 2019-06-20  1859          *   points to the CEP 
itself. This is a consequence of
6c52fdc244b5cc Bernard Metzler 2019-06-20  1860          *   - siw_cm_upcall() 
setting event.provider_data = cep and
6c52fdc244b5cc Bernard Metzler 2019-06-20  1861          *   - the IWCM's 
cm_conn_req_handler() setting provider_data of the
6c52fdc244b5cc Bernard Metzler 2019-06-20  1862          *     new passive-side 
IWCM id equal to event.provider_data
6c52fdc244b5cc Bernard Metzler 2019-06-20  1863          *   Uses: 
siw_accept(), siw_reject()
6c52fdc244b5cc Bernard Metzler 2019-06-20  1864          *
6c52fdc244b5cc Bernard Metzler 2019-06-20  1865          * o For an active-side 
IWCM id, id->provider_data is not used at all.
6c52fdc244b5cc Bernard Metzler 2019-06-20  1866          *
6c52fdc244b5cc Bernard Metzler 2019-06-20  1867          */
6c52fdc244b5cc Bernard Metzler 2019-06-20  1868         if (!id->provider_data) 
{
6c52fdc244b5cc Bernard Metzler 2019-06-20  1869                 
id->provider_data =
6c52fdc244b5cc Bernard Metzler 2019-06-20  1870                         
kmalloc(sizeof(struct list_head), GFP_KERNEL);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1871                 if 
(!id->provider_data) {
6c52fdc244b5cc Bernard Metzler 2019-06-20  1872                         rv = 
-ENOMEM;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1873                         goto 
error;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1874                 }
6c52fdc244b5cc Bernard Metzler 2019-06-20  1875                 
INIT_LIST_HEAD((struct list_head *)id->provider_data);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1876         }
6c52fdc244b5cc Bernard Metzler 2019-06-20  1877         
list_add_tail(&cep->listenq, (struct list_head *)id->provider_data);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1878         cep->state = 
SIW_EPSTATE_LISTENING;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1879  
33fb27fd54465c Bernard Metzler 2020-02-28  1880         siw_dbg(id->device, 
"Listen at laddr %pISp\n", &id->local_addr);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1881  
6c52fdc244b5cc Bernard Metzler 2019-06-20  1882         return 0;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1883  
6c52fdc244b5cc Bernard Metzler 2019-06-20  1884  error:
6c52fdc244b5cc Bernard Metzler 2019-06-20  1885         siw_dbg(id->device, 
"failed: %d\n", rv);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1886  
6c52fdc244b5cc Bernard Metzler 2019-06-20  1887         if (cep) {
6c52fdc244b5cc Bernard Metzler 2019-06-20 @1888                 
siw_cep_set_inuse(cep);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1889  
6c52fdc244b5cc Bernard Metzler 2019-06-20  1890                 if (cep->cm_id) 
{
6c52fdc244b5cc Bernard Metzler 2019-06-20  1891                         
cep->cm_id->rem_ref(cep->cm_id);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1892                         
cep->cm_id = NULL;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1893                 }
6c52fdc244b5cc Bernard Metzler 2019-06-20  1894                 cep->sock = 
NULL;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1895                 
siw_socket_disassoc(s);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1896                 cep->state = 
SIW_EPSTATE_CLOSED;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1897  
6c52fdc244b5cc Bernard Metzler 2019-06-20 @1898                 
siw_cep_set_free(cep);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1899                 
siw_cep_put(cep);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1900         }
6c52fdc244b5cc Bernard Metzler 2019-06-20  1901         sock_release(s);
6c52fdc244b5cc Bernard Metzler 2019-06-20  1902  
6c52fdc244b5cc Bernard Metzler 2019-06-20  1903         return rv;
6c52fdc244b5cc Bernard Metzler 2019-06-20  1904  }
6c52fdc244b5cc Bernard Metzler 2019-06-20  1905  

:::::: The code at line 1898 was first introduced by commit
:::::: 6c52fdc244b5ccc468006fd65a504d4ee33743c7 rdma/siw: connection management

:::::: TO: Bernard Metzler <b...@zurich.ibm.com>
:::::: CC: Jason Gunthorpe <j...@mellanox.com>

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

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-le...@lists.01.org

Reply via email to