Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1427783AbdDWHKY (ORCPT ); Sun, 23 Apr 2017 03:10:24 -0400 Received: from m50-135.163.com ([123.125.50.135]:59291 "EHLO m50-135.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1427745AbdDWHKP (ORCPT ); Sun, 23 Apr 2017 03:10:15 -0400 From: Pan Bian To: Jon Maloy , Ying Xue , "David S. Miller" Cc: netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH 1/1] tipc: check return value of nlmsg_new Date: Sun, 23 Apr 2017 15:09:19 +0800 Message-Id: <1492931359-25004-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: D9GowADHTvcfU_xYKg93AA--.176S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrtF4xZF1kCF48try5KrWfZrb_yoW3ZrbEqF 97W348G348Gwn3Cr42y3yUXF92qws5G3Wku3yxG34UK34DJrZ8Gws5ZrnxArWxGrZ7uas8 CF4UCF1fCr17GjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU1Gg4DUUUUU== X-Originating-IP: [123.118.194.153] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/1tbiQAHCclSISvK5cQAAsd Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 779 Lines: 27 Function nlmsg_new() will return a NULL pointer if there is no enough memory, and its return value should be checked before it is used. However, in function tipc_nl_node_get_monitor(), the validation of the return value of function nlmsg_new() is missed. This patch fixes the bug. Signed-off-by: Pan Bian --- net/tipc/node.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/tipc/node.c b/net/tipc/node.c index 4512e83..568e48d 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -2098,6 +2098,8 @@ int tipc_nl_node_get_monitor(struct sk_buff *skb, struct genl_info *info) int err; msg.skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); + if (!msg.skb) + return -ENOMEM; msg.portid = info->snd_portid; msg.seq = info->snd_seq; -- 1.9.1