From: Zhouyang Jia <jiazhouyang09@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Zhouyang Jia <jiazhouyang09@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH] staging: gdm724x: add error handling for nlmsg_put
Date: Mon, 11 Jun 2018 13:09:24 +0800 [thread overview]
Message-ID: <1528693766-31570-1-git-send-email-jiazhouyang09@gmail.com> (raw)
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;
+
memcpy(NLMSG_DATA(nlh), msg, len);
NETLINK_CB(skb).portid = 0;
NETLINK_CB(skb).dst_group = 0;
--
2.7.4
next reply other threads:[~2018-06-11 5:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-11 5:09 Zhouyang Jia [this message]
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
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=1528693766-31570-1-git-send-email-jiazhouyang09@gmail.com \
--to=jiazhouyang09@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--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®