[bug report] RDMA/restrack: Convert internal DB from hash to XArray

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[ I don't know why this warning is only showing up now but I grepped my
  outbox and apparently it's new...  *shrug*  -dan ]

Hello Leon Romanovsky,

The patch fd47c2f99f04: "RDMA/restrack: Convert internal DB from hash
to XArray" from Feb 18, 2019, leads to the following static checker
warning:

	drivers/infiniband/core/restrack.c:261 rdma_restrack_add()
	warn: 'ret' can be either negative or positive

drivers/infiniband/core/restrack.c
   220  void rdma_restrack_add(struct rdma_restrack_entry *res)
   221  {
   222          struct ib_device *dev = res_to_dev(res);
   223          struct rdma_restrack_root *rt;
   224          int ret = 0;
   225  
   226          if (!dev)
   227                  return;
   228  
   229          if (res->no_track)
   230                  goto out;
   231  
   232          rt = &dev->res[res->type];
   233  
   234          if (res->type == RDMA_RESTRACK_QP) {
   235                  /* Special case to ensure that LQPN points to right QP */
   236                  struct ib_qp *qp = container_of(res, struct ib_qp, res);
   237  
   238                  WARN_ONCE(qp->qp_num >> 24 || qp->port >> 8,
   239                            "QP number 0x%0X and port 0x%0X", qp->qp_num,
   240                            qp->port);
   241                  res->id = qp->qp_num;
   242                  if (qp->qp_type == IB_QPT_SMI || qp->qp_type == IB_QPT_GSI)
   243                          res->id |= qp->port << 24;
   244                  ret = xa_insert(&rt->xa, res->id, res, GFP_KERNEL);
   245                  if (ret)
   246                          res->id = 0;
   247          } else if (res->type == RDMA_RESTRACK_COUNTER) {
   248                  /* Special case to ensure that cntn points to right counter */
   249                  struct rdma_counter *counter;
   250  
   251                  counter = container_of(res, struct rdma_counter, res);
   252                  ret = xa_insert(&rt->xa, counter->id, res, GFP_KERNEL);
   253                  res->id = ret ? 0 : counter->id;
   254          } else {
   255                  ret = xa_alloc_cyclic(&rt->xa, &res->id, res, xa_limit_32b,
                              ^^^^^^^^^^^^^^^
This sometimes returns 1 on success.

   256                                        &rt->next_id, GFP_KERNEL);
   257          }
   258  
   259  out:
   260          if (!ret)

if (ret >= 0)?

   261                  res->valid = true;
   262  }

regards,
dan carpenter



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux