From patchwork Sat Aug 12 12:04:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 800873 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xV0ws6MPMz9t3C for ; Sat, 12 Aug 2017 22:07:09 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752220AbdHLMHI (ORCPT ); Sat, 12 Aug 2017 08:07:08 -0400 Received: from orbyte.nwl.cc ([151.80.46.58]:36749 "EHLO mail.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752293AbdHLMHD (ORCPT ); Sat, 12 Aug 2017 08:07:03 -0400 Received: from mail.nwl.cc (orbyte.nwl.cc [127.0.0.1]) by mail.nwl.cc (Postfix) with ESMTP id C2D8E683D9; Sat, 12 Aug 2017 14:07:02 +0200 (CEST) Received: from xsao (localhost [IPv6:::1]) by mail.nwl.cc (Postfix) with ESMTP id 8F3DA681D7; Sat, 12 Aug 2017 14:07:02 +0200 (CEST) From: Phil Sutter To: Stephen Hemminger Cc: netdev@vger.kernel.org Subject: [iproute PATCH 23/51] ifstat: Fix memleak in error case Date: Sat, 12 Aug 2017 14:04:42 +0200 Message-Id: <20170812120510.28750-24-phil@nwl.cc> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20170812120510.28750-1-phil@nwl.cc> References: <20170812120510.28750-1-phil@nwl.cc> X-Virus-Scanned: ClamAV using ClamSMTP Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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));