RDMA/nes: Fix for crash when registering zero length MR for CQ
authorTatyana Nikolova <Tatyana.E.Nikolova@intel.com>
Thu, 6 Dec 2012 20:05:02 +0000 (20:05 +0000)
committerRoland Dreier <roland@purestorage.com>
Sat, 8 Dec 2012 08:31:03 +0000 (00:31 -0800)
Signed-off-by: Tatyana Nikolova <Tatyana.E.Nikolova@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/hw/nes/nes_verbs.c

index c47ec2599bc9b67964fb9667975401570bec9e65..07e4fbad987ab66f2d1a80af52e6c76dfb315910 100644 (file)
@@ -2561,6 +2561,11 @@ static struct ib_mr *nes_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
                        return ibmr;
                case IWNES_MEMREG_TYPE_QP:
                case IWNES_MEMREG_TYPE_CQ:
+                       if (!region->length) {
+                               nes_debug(NES_DBG_MR, "Unable to register zero length region for CQ\n");
+                               ib_umem_release(region);
+                               return ERR_PTR(-EINVAL);
+                       }
                        nespbl = kzalloc(sizeof(*nespbl), GFP_KERNEL);
                        if (!nespbl) {
                                nes_debug(NES_DBG_MR, "Unable to allocate PBL\n");