tipc: fix a missing check of genlmsg_put
authorKangjie Lu <kjlu@umn.edu>
Wed, 26 Dec 2018 06:09:04 +0000 (00:09 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Dec 2019 14:37:50 +0000 (15:37 +0100)
[ Upstream commit 46273cf7e009231d2b6bc10a926e82b8928a9fb2 ]

genlmsg_put could fail. The fix inserts a check of its return value, and
if it fails, returns -EMSGSIZE.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/tipc/netlink_compat.c

index 1c8ac0c11008c753729c768ab42ef9c4074facdc..91d51a595ac23bb9383a31ce6aa05b20af071bf5 100644 (file)
@@ -974,6 +974,8 @@ static int tipc_nl_compat_publ_dump(struct tipc_nl_compat_msg *msg, u32 sock)
 
        hdr = genlmsg_put(args, 0, 0, &tipc_genl_family, NLM_F_MULTI,
                          TIPC_NL_PUBL_GET);
+       if (!hdr)
+               return -EMSGSIZE;
 
        nest = nla_nest_start(args, TIPC_NLA_SOCK);
        if (!nest) {