Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1628944 > unrolled thread
| Started by | Pan Bian <bianpan2016@163.com> |
|---|---|
| First post | 2017-04-23 11:10 +0200 |
| Last post | 2017-04-23 19:00 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 1/1] iw_cxgb4: check return value of alloc_skb Pan Bian <bianpan2016@163.com> - 2017-04-23 11:10 +0200
Re: [PATCH 1/1] iw_cxgb4: check return value of alloc_skb Leon Romanovsky <leon@kernel.org> - 2017-04-23 19:00 +0200
| From | Pan Bian <bianpan2016@163.com> |
|---|---|
| Date | 2017-04-23 11:10 +0200 |
| Subject | [PATCH 1/1] iw_cxgb4: check return value of alloc_skb |
| Message-ID | <tzlGO-6uj-19@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | Leon Romanovsky <leon@kernel.org> |
|---|---|
| Date | 2017-04-23 19:00 +0200 |
| Message-ID | <tzt1D-2zh-3@gated-at.bofh.it> |
| In reply to | #1628944 |
[Multipart message — attachments visible in raw view] — view raw
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@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; 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 > >
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web