lkml.org 
[lkml]   [2019]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] infiniband: cxgb4: fix a potential NULL pointer dereference
On Saturday, March 03/23/19, 2019 at 08:07:46 +0530, Kangjie Lu wrote:
>
>
> > On Mar 8, 2019, at 11:19 PM, Kangjie Lu <kjlu@umn.edu> wrote:
> >
> > get_skb may fail and return NULL. The fix returns "ENOMEM"
> > when it fails to avoid NULL dereference.
> >
> > Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> > ---
> > drivers/infiniband/hw/cxgb4/cm.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
> > index 8221813219e5..502a54d57e2c 100644
> > --- a/drivers/infiniband/hw/cxgb4/cm.c
> > +++ b/drivers/infiniband/hw/cxgb4/cm.c
> > @@ -1919,6 +1919,9 @@ static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid)
> > int win;
> >
> > skb = get_skb(NULL, sizeof(*req), GFP_KERNEL);
> > + if (!skb)
> > + return -ENOMEM;
> > +
>
> Can someone review this patch? Thanks.

Sorry for the late response.
I recommend an error print before the return.
---
if (!skb) {
pr_err("%s - failed to alloc skb\n", __func__);
return -ENOMEM;
}
---
Thanks for the patch!
- Bharat.
>
> > req = __skb_put_zero(skb, sizeof(*req));
> > req->op_compl = htonl(WR_OP_V(FW_OFLD_CONNECTION_WR));
> > req->len16_pkd = htonl(FW_WR_LEN16_V(DIV_ROUND_UP(sizeof(*req), 16)));
> > --
> > 2.17.1
> >
>

\
 
 \ /
  Last update: 2019-03-27 14:40    [W:0.130 / U:4.860 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site