RDMA/amso1100: Add check for NULL reply_msg in c2_intr()
authorTom Tucker <tom@opengridcomputing.com>
Thu, 17 Apr 2008 04:09:34 +0000 (21:09 -0700)
committerRoland Dreier <rolandd@cisco.com>
Thu, 17 Apr 2008 04:09:34 +0000 (21:09 -0700)
Fix a place where we might dereference a NULL pointer; this fixes
Coverity CID 1392.  On inspection I also found a place where we could
attempt to kmem_cache_free() a NULL pointer, so fix this too.

Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/amso1100/c2_cq.c
drivers/infiniband/hw/amso1100/c2_intr.c

index d2b3366..bb17cce 100644 (file)
@@ -422,8 +422,8 @@ void c2_free_cq(struct c2_dev *c2dev, struct c2_cq *cq)
                goto bail1;
 
        reply = (struct c2wr_cq_destroy_rep *) (unsigned long) (vq_req->reply_msg);
-
-       vq_repbuf_free(c2dev, reply);
+       if (reply)
+               vq_repbuf_free(c2dev, reply);
       bail1:
        vq_req_free(c2dev, vq_req);
       bail0:
index 0d0bc33..3b50954 100644 (file)
@@ -174,7 +174,11 @@ static void handle_vq(struct c2_dev *c2dev, u32 mq_index)
                return;
        }
 
-       err = c2_errno(reply_msg);
+       if (reply_msg)
+               err = c2_errno(reply_msg);
+       else
+               err = -ENOMEM;
+
        if (!err) switch (req->event) {
        case IW_CM_EVENT_ESTABLISHED:
                c2_set_qp_state(req->qp,