mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Zhouyang Jia <jiazhouyang09@gmail.com>
Cc: devel@driverdev.osuosl.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] staging: gdm724x: add error handling for nlmsg_put
Date: Thu, 14 Jun 2018 16:58:45 +0300	[thread overview]
Message-ID: <20180614135845.xzej3zrnhc2bf726@mwanda> (raw)
In-Reply-To: <1528975913-51879-1-git-send-email-jiazhouyang09@gmail.com>

On Thu, Jun 14, 2018 at 07:31:51PM +0800, Zhouyang Jia wrote:
> When nlmsg_put fails, the lack of error-handling code may
> cause unexpected results.
> 
> This patch adds error-handling code after calling nlmsg_put.
> 
> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
> ---
> v1->v2:
> - Add some cleanup
> ---
>  drivers/staging/gdm724x/netlink_k.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/staging/gdm724x/netlink_k.c b/drivers/staging/gdm724x/netlink_k.c
> index abe2425..16da03b 100644
> --- a/drivers/staging/gdm724x/netlink_k.c
> +++ b/drivers/staging/gdm724x/netlink_k.c
> @@ -119,6 +119,11 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len)
>  	seq++;
>  
>  	nlh = nlmsg_put(skb, 0, seq, type, len, 0);
> +	if (!nlh) {
> +		kfree_skb(skb);
> +		return -EMSGSIZE;
> +	}

As I mentioned earlier, this patch is not required because the we just
allocated the skb and we know that it is large enough.

regards,
dan carpenter



      reply	other threads:[~2018-06-14 13:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-11  5:09 [PATCH] " Zhouyang Jia
2018-06-12 11:55 ` Dan Carpenter
     [not found]   ` <CABb2Tx+7E9dxV0=D0t80CPnxfLJpEo0+eNG-c_2XH2tZD-C8BA@mail.gmail.com>
2018-06-14 14:14     ` Dan Carpenter
2018-06-14 14:18     ` Dan Carpenter
2018-06-14 11:31 ` [PATCH v2] " Zhouyang Jia
2018-06-14 13:58   ` Dan Carpenter [this message]

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=20180614135845.xzej3zrnhc2bf726@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jiazhouyang09@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®