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] staging: gdm724x: add error handling for nlmsg_put
Date: Tue, 12 Jun 2018 14:55:25 +0300 [thread overview]
Message-ID: <20180612115525.yg2mnhlcz6ok3dyo@mwanda> (raw)
In-Reply-To: <1528693766-31570-1-git-send-email-jiazhouyang09@gmail.com>
On Mon, Jun 11, 2018 at 01:09:24PM +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>
> ---
> drivers/staging/gdm724x/netlink_k.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/staging/gdm724x/netlink_k.c b/drivers/staging/gdm724x/netlink_k.c
> index abe2425..4623140 100644
> --- a/drivers/staging/gdm724x/netlink_k.c
> +++ b/drivers/staging/gdm724x/netlink_k.c
> @@ -119,6 +119,9 @@ 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)
> + return -EMSGSIZE;
This can't fail. We just allocated skb on the line before and we
allocated enough space for "len". Also if we *did* hit a bug here then
we would need to do some more cleanup instead of a direct return.
regards,
dan carpenter
next prev parent reply other threads:[~2018-06-12 11:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-11 5:09 Zhouyang Jia
2018-06-12 11:55 ` Dan Carpenter [this message]
[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
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=20180612115525.yg2mnhlcz6ok3dyo@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®