infiniband: cxgb4: fix a potential NULL pointer dereference
Subsystems (2)
PATCH 1/1 infiniband: cxgb4: fix a potential NULL pointer dereference
get_skb may fail and return NULL. The fix returns "ENOMEM" when it fails to avoid NULL dereference.
--- drivers/infiniband/hw/cxgb4/cm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/hw/cxgb4/cm.c +3 -0
@@ -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 ; + 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 )));
Signature · 1 line
2.17.1
Quoted 17 lines · Kangjie Lu
get_skbmay fail and return NULL. The fix returns "ENOMEM" when it fails to avoid NULL dereference.Signed-off-by Kangjie Lu <[email protected]>---
drivers/infiniband/hw/cxgb4/cm.c| 3 +++1 file changed, 3 insertions(+)drivers/infiniband/hw/cxgb4/cm.c +0
-0
drivers/infiniband/hw/cxgb4/cm.c static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid) · line 1924
Quoted 6 lines
drivers/infiniband/hw/cxgb4/cm.c +3
-0@@ -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.
Quoted 6 lines
drivers/infiniband/hw/cxgb4/cm.c +0
-0req =__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 )));Signature · 1 line
2.17.1
Quoted 16 lines · Kangjie Lu
Quoted 16 lines · Kangjie Lu
get_skbmay fail and return NULL. The fix returns "ENOMEM" when it fails to avoid NULL dereference.Signed-off-by Kangjie Lu <[email protected]>---
drivers/infiniband/hw/cxgb4/cm.c| 3 +++1 file changed, 3 insertions(+)drivers/infiniband/hw/cxgb4/cm.c +0
-0@@ -1919,6 +1919,9 @@ static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid)int win;
Quoted 6 lines
drivers/infiniband/hw/cxgb4/cm.c static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid) · line 1924
Quoted 4 lines
drivers/infiniband/hw/cxgb4/cm.c +3
-0skb =get_skb (NULL ,sizeof (*req),GFP_KERNEL ); +if (!skb) +return -ENOMEM ; +Can someone review this patch? Thanks.
Hi Kangjie,
Please change the patch description to the imperative mood (see also https://git.kernel.org/pub/scm/git/git.git/tree/Documentation/SubmittingPatches). A good way to invite feedback is to add a relevant Cc-list to a patch. The output of scripts/get_maintainer.pl can be a good start.
Bart.
Potnuri Bharat Teja
maintainerQuoted 19 lines · Kangjie Lu
Quoted 19 lines · Kangjie Lu
get_skbmay fail and return NULL. The fix returns "ENOMEM" when it fails to avoid NULL dereference.Signed-off-by Kangjie Lu <[email protected]>---
drivers/infiniband/hw/cxgb4/cm.c| 3 +++1 file changed, 3 insertions(+)drivers/infiniband/hw/cxgb4/cm.c +0
-0@@ -1919,6 +1919,9 @@ static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid)int win;
Quoted 6 lines
drivers/infiniband/hw/cxgb4/cm.c static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid) · line 1924
Quoted 4 lines
drivers/infiniband/hw/cxgb4/cm.c +3
-0skb =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.
Quoted 8 lines
Quoted 7 lines
drivers/infiniband/hw/cxgb4/cm.c +0
-0req =__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 )));Signature · 1 line
2.17.1
Quoted 25 lines · Potnuri Bharat Teja
Quoted 17 lines · Kangjie Lu
Quoted 17 lines · Kangjie Lu
get_skbmay fail and return NULL. The fix returns "ENOMEM" when it fails to avoid NULL dereference.Signed-off-by Kangjie Lu <[email protected]>
drivers/infiniband/hw/cxgb4/cm.c| 3 +++1 file changed, 3 insertions(+)drivers/infiniband/hw/cxgb4/cm.c +1
-0+++ 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;Quoted 6 lines
drivers/infiniband/hw/cxgb4/cm.c static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid) · line 1924
Quoted 4 lines
drivers/infiniband/hw/cxgb4/cm.c +3
-0skb =get_skb (NULL ,sizeof (*req),GFP_KERNEL ); +if (!skb) +return -ENOMEM ; +Can someone review this patch? Thanks.
Quoted 6 lines
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; }
no error prints on memory allocation failure, the kernel already prints enough on this
Jason
Quoted 33 lines · Jason Gunthorpe
Quoted 25 lines · Potnuri Bharat Teja
Quoted 17 lines · Kangjie Lu
Quoted 17 lines · Kangjie Lu
get_skbmay fail and return NULL. The fix returns "ENOMEM" when it fails to avoid NULL dereference.Signed-off-by Kangjie Lu <[email protected]>
drivers/infiniband/hw/cxgb4/cm.c| 3 +++1 file changed, 3 insertions(+)drivers/infiniband/hw/cxgb4/cm.c +1
-0+++ 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;Quoted 6 lines
drivers/infiniband/hw/cxgb4/cm.c static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid) · line 1924
Quoted 4 lines
drivers/infiniband/hw/cxgb4/cm.c +3
-0skb =get_skb (NULL ,sizeof (*req),GFP_KERNEL ); +if (!skb) +return -ENOMEM ; +Can someone review this patch? Thanks.
Quoted 6 lines
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; }
Quoted 2 lines
no error prints on memory allocation failure, the kernel already prints enough on this
Ok.
Quoted 34 lines · Potnuri Bharat Teja
Quoted 33 lines · Jason Gunthorpe
Quoted 31 lines · Potnuri Bharat Teja
Quoted 17 lines · Kangjie Lu
Quoted 17 lines · Kangjie Lu
get_skbmay fail and return NULL. The fix returns "ENOMEM" when it fails to avoid NULL dereference.Signed-off-by Kangjie Lu <[email protected]>
drivers/infiniband/hw/cxgb4/cm.c| 3 +++1 file changed, 3 insertions(+)drivers/infiniband/hw/cxgb4/cm.c +1
-0+++ 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;Quoted 6 lines
drivers/infiniband/hw/cxgb4/cm.c static int send_fw_act_open_req(struct c4iw_ep *ep, unsigned int atid) · line 1924
Quoted 4 lines
drivers/infiniband/hw/cxgb4/cm.c +3
-0skb =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; }
Quoted 5 lines
Quoted 2 lines
no error prints on memory allocation failure, the kernel already prints enough on this
Ok.
It needs to be resent with Bart's comment addressed, and all the tags collected.
Jason
Quoted 4 lines · Kangjie Lu
get_skbmay fail and return NULL. The fix returns "ENOMEM" when it fails to avoid NULL dereference.Signed-off-by Kangjie Lu <[email protected]>
Quoted 18 lines
--- drivers/infiniband/hw/cxgb4/cm.c | 3 +++ 1 file changed, 3 insertions(+)drivers/infiniband/hw/cxgb4/cm.c +3
-0@@ -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 ; + 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 )));
Quoted 4 lines · Kangjie Lu
get_skbmay fail and return NULL. The fix returns "ENOMEM" when it fails to avoid NULL dereference.Signed-off-by Kangjie Lu <[email protected]>
Quoted 18 lines
--- drivers/infiniband/hw/cxgb4/cm.c | 3 +++ 1 file changed, 3 insertions(+)drivers/infiniband/hw/cxgb4/cm.c +3
-0@@ -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 ; + 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 )));