From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuval Shaia Subject: Re: [PATCH] RDS: IB: NULL dereference on error in rds_ib_alloc_frmr() Date: Wed, 14 Jun 2017 15:54:24 +0300 Message-ID: <20170614125423.GA3329@yuvallap> References: <20170614103924.GK29394@elgon.mountain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20170614103924.GK29394-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org> Sender: linux-rdma-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Dan Carpenter Cc: Santosh Shilimkar , Avinash Repaka , linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, rds-devel-N0ozoZBvEnrZJqsBc5GL+g@public.gmane.org, kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-rdma@vger.kernel.org On Wed, Jun 14, 2017 at 01:39:24PM +0300, Dan Carpenter wrote: > We accidentally return ERR_PTR(0) if ib_alloc_mr() fails. The caller > is expecting error pointers so it results in a NULL dereference. > > Fixes: 1659185fb4d0 ("RDS: IB: Support Fastreg MR (FRMR) memory registration mode") > Signed-off-by: Dan Carpenter > > diff --git a/net/rds/ib_frmr.c b/net/rds/ib_frmr.c > index 48332a6ed738..74a66cc162ed 100644 > --- a/net/rds/ib_frmr.c > +++ b/net/rds/ib_frmr.c > @@ -38,7 +38,7 @@ static struct rds_ib_mr *rds_ib_alloc_frmr(struct rds_ib_device *rds_ibdev, > struct rds_ib_mr_pool *pool; > struct rds_ib_mr *ibmr = NULL; > struct rds_ib_frmr *frmr; > - int err = 0; > + int err; Can we trust it'll be zero? > > if (npages <= RDS_MR_8K_MSG_SIZE) > pool = rds_ibdev->mr_8k_pool; > @@ -61,6 +61,7 @@ static struct rds_ib_mr *rds_ib_alloc_frmr(struct rds_ib_device *rds_ibdev, > pool->fmr_attr.max_pages); > if (IS_ERR(frmr->mr)) { > pr_warn("RDS/IB: %s failed to allocate MR", __func__); > + err = -ENOMEM; > goto out_no_cigar; > } > > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html