[bug report] IB/rdmavt: Add completion queue functions

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

 



Hello Shamir Rabinovitch,

The patch ff23dfa13457: ("IB: Pass only ib_udata in function prototypes")
leads to the following static checker warning:

	drivers/infiniband/sw/rdmavt/cq.c:273 rvt_create_cq()
	error: 'cq->ip' dereferencing possible ERR_PTR()

drivers/infiniband/sw/rdmavt/cq.c
   217          /*
   218           * Return the address of the WC as the offset to mmap.
   219           * See rvt_mmap() for details.
   220           */
   221          if (udata && udata->outlen >= sizeof(__u64)) {
   222                  cq->ip = rvt_create_mmap_info(rdi, sz, udata, wc);

This warning is a false positive which is kind of involved to explain.
This function returns a mix of error pointers and NULL.  Smatch parses
correctly so it knows that "cq->ip" isn't an error pointer here.  But
really it shouldn't return error pointers.

When a function returns error pointers and NULL the NULL return should
be treated as a special success case.  For example, we could say
"p = get_some_feature();"  If it get_some_feature() returns an error
pointer that means kmalloc() failed or whatever, but if it returns a
NULL that means the feature is disabled.

   223                  if (!cq->ip) {
   224                          err = -ENOMEM;
   225                          goto bail_wc;
   226                  }
   227  
   228                  err = ib_copy_to_udata(udata, &cq->ip->offset,
   229                                         sizeof(cq->ip->offset));
   230                  if (err)
   231                          goto bail_ip;
   232          }

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