From mboxrd@z Thu Jan 1 00:00:00 1970 From: Phil Sutter Subject: [iproute PATCH v2 2/5] ifstat: Fix memleak in error case Date: Thu, 17 Aug 2017 19:09:28 +0200 Message-ID: <20170817170931.24435-3-phil@nwl.cc> References: <20170817170931.24435-1-phil@nwl.cc> Cc: netdev@vger.kernel.org To: Stephen Hemminger Return-path: Received: from orbyte.nwl.cc ([151.80.46.58]:51625 "EHLO mail.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753386AbdHQRK6 (ORCPT ); Thu, 17 Aug 2017 13:10:58 -0400 In-Reply-To: <20170817170931.24435-1-phil@nwl.cc> Sender: netdev-owner@vger.kernel.org List-ID: Signed-off-by: Phil Sutter --- misc/ifstat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/misc/ifstat.c b/misc/ifstat.c index a853ee6d7e3b3..8fa354265a9a1 100644 --- a/misc/ifstat.c +++ b/misc/ifstat.c @@ -143,8 +143,10 @@ static int get_nlmsg_extended(const struct sockaddr_nl *who, struct rtattr *attr; attr = parse_rtattr_one_nested(sub_type, tb[filter_type]); - if (attr == NULL) + if (attr == NULL) { + free(n); return 0; + } memcpy(&n->val, RTA_DATA(attr), sizeof(n->val)); } memset(&n->rate, 0, sizeof(n->rate)); -- 2.13.1