Skip to contentSkip to conversation

IB/hfi1: Prevent NULL pointer deferences in caching code

bug report Dan Carpenter 2 participants 2 messages Oct 12, 2016 InfiniBand

lore
Share & tools
lore
#0 lore raw

Hello Mitko Haralanov,

The patch f19bd643dbde: "IB/hfi1: Prevent NULL pointer deferences in caching code" from Apr 12, 2016, leads to the following static checker warning:

	drivers/infiniband/hw/hfi1/user_sdma.c:1147 pin_vector_pages()
	warn: 'rb_node' isn't an ERR_PTR

drivers/infiniband/hw/hfi1/user_sdma.c
1135 static int pin_vector_pages(struct user_sdma_request *req,
1136 struct user_sdma_iovec *iovec)
1137 {

  1138          int ret = 0, pinned, npages, cleared;
  1139          struct page **pages;
  1140          struct hfi1_user_sdma_pkt_q *pq = req->pq;
  1141          struct sdma_mmu_node *node = NULL;
  1142          struct mmu_rb_node *rb_node;
  1143  
  1144          rb_node = hfi1_mmu_rb_extract(pq->handler,
  1145                                        (unsigned long)iovec->iov.iov_base,
  1146                                        iovec->iov.iov_len);
  1147          if (rb_node && !IS_ERR(rb_node))
                                ^^^^^^^^^^^^^^^

hfi1_mmu_rb_extract() never returns error pointers. Plz delete.

  1148                  node = container_of(rb_node, struct sdma_mmu_node, rb);
  1149          else
  1150                  rb_node = NULL;
  1151  
  1152          if (!node) {
  1153                  node = kzalloc(sizeof(*node), GFP_KERNEL);
  1154                  if (!node)
  1155                          return -ENOMEM;
  1156  
  1157                  node->rb.addr = (unsigned long)iovec->iov.iov_base;
  1158                  node->pq = pq;
  1159                  atomic_set(&node->refcount, 0);
  1160          }

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw

VGhhbmtzIERhbiwgd2UnbGwgdGFrZSBjYXJlIG9mIGl0Lg0KDQotRGVubnkNCg0KT24gV2VkLCAy MDE2LTEwLTEyIGF0IDA5OjA2ICswMzAwLCBEYW4gQ2FycGVudGVyIHdyb3RlOg0KPiBIZWxsbyBN aXR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sLm9yZw0K PiBNb3JlIG1ham9yZG9tbyBpbmZvIGF0wqDCoGh0dHA6Ly92Z2VyLmtlcm5lbC5vcmcvbWFqb3Jk b21vLWluZm8uaHRtbA==
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html