mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Pan Bian <bianpan2016@163.com>
Cc: Steve Wise <swise@chelsio.com>,
	Doug Ledford <dledford@redhat.com>,
	Sean Hefty <sean.hefty@intel.com>,
	Hal Rosenstock <hal.rosenstock@gmail.com>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] iw_cxgb4: check return value of alloc_skb
Date: Sun, 23 Apr 2017 19:51:41 +0300	[thread overview]
Message-ID: <20170423165141.GG14088@mtr-leonro.local> (raw)
In-Reply-To: <1492938551-17824-1-git-send-email-bianpan2016@163.com>

[-- Attachment #1: Type: text/plain, Size: 1230 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@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
>
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-04-23 16:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-23  9:09 Pan Bian
2017-04-23 16:51 ` Leon Romanovsky [this message]
2017-04-28 17:10 ` Doug Ledford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170423165141.GG14088@mtr-leonro.local \
    --to=leon@kernel.org \
    --cc=bianpan2016@163.com \
    --cc=dledford@redhat.com \
    --cc=hal.rosenstock@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sean.hefty@intel.com \
    --cc=swise@chelsio.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome