* [PATCH 1/1] iw_cxgb4: check return value of alloc_skb
@ 2017-04-23 9:09 Pan Bian
[not found] ` <1492938551-17824-1-git-send-email-bianpan2016-9Onoh4P/yGk@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Pan Bian @ 2017-04-23 9:09 UTC (permalink / raw)
To: Steve Wise, Doug Ledford, Sean Hefty, Hal Rosenstock
Cc: linux-rdma, linux-kernel, Pan Bian
Function alloc_skb() will return a NULL pointer when there is no enough
memory. However, the return value of alloc_skb() is directly used
without validation in function send_fw_pass_open_req(). This patches
checks the return value of alloc_skb() against NULL.
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/infiniband/hw/cxgb4/cm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 03a1b0e..196969c 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -3800,6 +3800,8 @@ static void send_fw_pass_open_req(struct c4iw_dev *dev, struct sk_buff *skb,
int ret;
req_skb = alloc_skb(sizeof(struct fw_ofld_connection_wr), GFP_KERNEL);
+ if (!req_skb)
+ return;
req = (struct fw_ofld_connection_wr *)__skb_put(req_skb, sizeof(*req));
memset(req, 0, sizeof(*req));
req->op_compl = htonl(WR_OP_V(FW_OFLD_CONNECTION_WR) | FW_WR_COMPL_F);
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread[parent not found: <1492938551-17824-1-git-send-email-bianpan2016-9Onoh4P/yGk@public.gmane.org>]
* Re: [PATCH 1/1] iw_cxgb4: check return value of alloc_skb [not found] ` <1492938551-17824-1-git-send-email-bianpan2016-9Onoh4P/yGk@public.gmane.org> @ 2017-04-23 16:51 ` Leon Romanovsky 2017-04-28 17:10 ` Doug Ledford 1 sibling, 0 replies; 3+ messages in thread From: Leon Romanovsky @ 2017-04-23 16:51 UTC (permalink / raw) To: Pan Bian Cc: Steve Wise, Doug Ledford, Sean Hefty, Hal Rosenstock, linux-rdma-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 1251 bytes --] On Sun, Apr 23, 2017 at 05:09:11PM +0800, Pan Bian wrote: > Function alloc_skb() will return a NULL pointer when there is no enough > memory. However, the return value of alloc_skb() is directly used > without validation in function send_fw_pass_open_req(). This patches > checks the return value of alloc_skb() against NULL. > > Signed-off-by: Pan Bian <bianpan2016-9Onoh4P/yGk@public.gmane.org> > --- > drivers/infiniband/hw/cxgb4/cm.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c > index 03a1b0e..196969c 100644 > --- a/drivers/infiniband/hw/cxgb4/cm.c > +++ b/drivers/infiniband/hw/cxgb4/cm.c > @@ -3800,6 +3800,8 @@ static void send_fw_pass_open_req(struct c4iw_dev *dev, struct sk_buff *skb, > int ret; > > req_skb = alloc_skb(sizeof(struct fw_ofld_connection_wr), GFP_KERNEL); > + if (!req_skb) > + return; The check is right, but the outcome is unpredictable. The function send_fw_pass_open_req() doesn't return any error and caller doesn't check it. > req = (struct fw_ofld_connection_wr *)__skb_put(req_skb, sizeof(*req)); > memset(req, 0, sizeof(*req)); > req->op_compl = htonl(WR_OP_V(FW_OFLD_CONNECTION_WR) | FW_WR_COMPL_F); > -- > 1.9.1 > > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] iw_cxgb4: check return value of alloc_skb [not found] ` <1492938551-17824-1-git-send-email-bianpan2016-9Onoh4P/yGk@public.gmane.org> 2017-04-23 16:51 ` Leon Romanovsky @ 2017-04-28 17:10 ` Doug Ledford 1 sibling, 0 replies; 3+ messages in thread From: Doug Ledford @ 2017-04-28 17:10 UTC (permalink / raw) To: Pan Bian, Steve Wise, Sean Hefty, Hal Rosenstock Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA On Sun, 2017-04-23 at 17:09 +0800, Pan Bian wrote: > Function alloc_skb() will return a NULL pointer when there is no > enough > memory. However, the return value of alloc_skb() is directly used > without validation in function send_fw_pass_open_req(). This patches > checks the return value of alloc_skb() against NULL. > > Signed-off-by: Pan Bian <bianpan2016-9Onoh4P/yGk@public.gmane.org> Thanks, applied. -- Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> GPG KeyID: B826A3330E572FDD Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD -- 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-04-28 17:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-23 9:09 [PATCH 1/1] iw_cxgb4: check return value of alloc_skb Pan Bian
[not found] ` <1492938551-17824-1-git-send-email-bianpan2016-9Onoh4P/yGk@public.gmane.org>
2017-04-23 16:51 ` Leon Romanovsky
2017-04-28 17:10 ` Doug Ledford
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).