Commit 56b2eca3 authored by Hariprasad S's avatar Hariprasad S Committed by Doug Ledford

RDMA/iw_cxgb4: Use kfree_skb instead of kfree

The commit 0f8ab0b6 ("RDMA/iw_cxgb4: Low resource fixes for Memory
registration") from Jun 10, 2016, leads to the following static checker
warning:

        drivers/infiniband/hw/cxgb4/mem.c:612 c4iw_alloc_mw()
        error: use kfree_skb() here instead of kfree(mhp->dereg_skb)

Also fixes skb leak in c4iw_dealloc_mw

Fixes: 0f8ab0b6 ("RDMA/iw_cxgb4: Low resource fixes for Memory registration")
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarSteve Wise <swise@opengridcomputing.com>
Signed-off-by: default avatarHariprasad Shenai <hariprasad@chelsio.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent dd6b0241
...@@ -603,16 +603,13 @@ struct ib_mw *c4iw_alloc_mw(struct ib_pd *pd, enum ib_mw_type type, ...@@ -603,16 +603,13 @@ struct ib_mw *c4iw_alloc_mw(struct ib_pd *pd, enum ib_mw_type type,
mhp->dereg_skb = alloc_skb(SGE_MAX_WR_LEN, GFP_KERNEL); mhp->dereg_skb = alloc_skb(SGE_MAX_WR_LEN, GFP_KERNEL);
if (!mhp->dereg_skb) { if (!mhp->dereg_skb) {
kfree(mhp); ret = -ENOMEM;
return ERR_PTR(-ENOMEM); goto free_mhp;
} }
ret = allocate_window(&rhp->rdev, &stag, php->pdid); ret = allocate_window(&rhp->rdev, &stag, php->pdid);
if (ret) { if (ret)
kfree(mhp->dereg_skb); goto free_skb;
kfree(mhp);
return ERR_PTR(ret);
}
mhp->rhp = rhp; mhp->rhp = rhp;
mhp->attr.pdid = php->pdid; mhp->attr.pdid = php->pdid;
mhp->attr.type = FW_RI_STAG_MW; mhp->attr.type = FW_RI_STAG_MW;
...@@ -620,13 +617,19 @@ struct ib_mw *c4iw_alloc_mw(struct ib_pd *pd, enum ib_mw_type type, ...@@ -620,13 +617,19 @@ struct ib_mw *c4iw_alloc_mw(struct ib_pd *pd, enum ib_mw_type type,
mmid = (stag) >> 8; mmid = (stag) >> 8;
mhp->ibmw.rkey = stag; mhp->ibmw.rkey = stag;
if (insert_handle(rhp, &rhp->mmidr, mhp, mmid)) { if (insert_handle(rhp, &rhp->mmidr, mhp, mmid)) {
deallocate_window(&rhp->rdev, mhp->attr.stag, mhp->dereg_skb); ret = -ENOMEM;
kfree(mhp->dereg_skb); goto dealloc_win;
kfree(mhp);
return ERR_PTR(-ENOMEM);
} }
PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag); PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag);
return &(mhp->ibmw); return &(mhp->ibmw);
dealloc_win:
deallocate_window(&rhp->rdev, mhp->attr.stag, mhp->dereg_skb);
free_skb:
kfree_skb(mhp->dereg_skb);
free_mhp:
kfree(mhp);
return ERR_PTR(ret);
} }
int c4iw_dealloc_mw(struct ib_mw *mw) int c4iw_dealloc_mw(struct ib_mw *mw)
...@@ -640,6 +643,7 @@ int c4iw_dealloc_mw(struct ib_mw *mw) ...@@ -640,6 +643,7 @@ int c4iw_dealloc_mw(struct ib_mw *mw)
mmid = (mw->rkey) >> 8; mmid = (mw->rkey) >> 8;
remove_handle(rhp, &rhp->mmidr, mmid); remove_handle(rhp, &rhp->mmidr, mmid);
deallocate_window(&rhp->rdev, mhp->attr.stag, mhp->dereg_skb); deallocate_window(&rhp->rdev, mhp->attr.stag, mhp->dereg_skb);
kfree_skb(mhp->dereg_skb);
kfree(mhp); kfree(mhp);
PDBG("%s ib_mw %p mmid 0x%x ptr %p\n", __func__, mw, mmid, mhp); PDBG("%s ib_mw %p mmid 0x%x ptr %p\n", __func__, mw, mmid, mhp);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment