Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751240AbdFDMuF (ORCPT ); Sun, 4 Jun 2017 08:50:05 -0400 Received: from cmccmta2.chinamobile.com ([221.176.66.80]:19262 "EHLO cmccmta2.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751139AbdFDMt6 (ORCPT ); Sun, 4 Jun 2017 08:49:58 -0400 X-RM-TRANSID: 2ee6593401f252b-2b36f X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2ee3593401f19bb-b0fb1 From: Haishuang Yan To: "David S. Miller" , Arkadi Sharshevsky , Jiri Pirko Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Haishuang Yan Subject: [PATCH] devlink: fix potential memort leak Date: Sun, 4 Jun 2017 20:49:52 +0800 Message-Id: <1496580592-13659-1-git-send-email-yanhaishuang@cmss.chinamobile.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 753 Lines: 28 We must free allocated skb when genlmsg_put() return fails. Fixes: 1555d204e743 ("devlink: Support for pipeline debug (dpipe)") Signed-off-by: Haishuang Yan --- net/core/devlink.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/core/devlink.c b/net/core/devlink.c index b0b87a2..70b69c6 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -1680,8 +1680,10 @@ static int devlink_dpipe_tables_fill(struct genl_info *info, hdr = genlmsg_put(skb, info->snd_portid, info->snd_seq, &devlink_nl_family, NLM_F_MULTI, cmd); - if (!hdr) + if (!hdr) { + nlmsg_free(skb); return -EMSGSIZE; + } if (devlink_nl_put_handle(skb, devlink)) goto nla_put_failure; -- 1.8.3.1