From patchwork Thu May 18 15:34:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 9734699 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3F6D1601BC for ; Thu, 18 May 2017 15:35:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2411E28882 for ; Thu, 18 May 2017 15:35:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1636528881; Thu, 18 May 2017 15:35:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A865B28881 for ; Thu, 18 May 2017 15:35:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932474AbdERPe4 (ORCPT ); Thu, 18 May 2017 11:34:56 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:34597 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932298AbdERPey (ORCPT ); Thu, 18 May 2017 11:34:54 -0400 Received: by mail-pg0-f67.google.com with SMTP id u187so6378104pgb.1; Thu, 18 May 2017 08:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bDMeTzisvUsOB8uHnGG6gMPqjAurDXfVsAVnecr3yFY=; b=SqmlQeY72ReYmyLsyMINK7j5dsOLoLnAfcTNVZAn8l/FMGZWMyXtjlNJ+ZdhB1EQvQ ztttO+XkcWwVOpOQ8mNpiVJBI3l4G77mkVcHxVWmttK4rMACBxFoglFnq3h5ry3HslrW oG9f4TGG91pbXblvK5LdbdIMtWu2lFKaoNegcbrmdqGFcsrYU1B7mjxQF0o0dnJibNFt mNo8dfzg2CabgfWYLZg1OXsQFvW1oMWj2h5Z8cDHOq9LoYb7dWNKwmLD4fhGznZKYqZh 7PXVq1A5U1tLfNn5UwqhVuqyrdbofdV92axXJNZFNPbDrpgm1WzwzgemMguVMXc2wuZb yWuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bDMeTzisvUsOB8uHnGG6gMPqjAurDXfVsAVnecr3yFY=; b=LL/9iJuJR9Arag/B1vCK7zhzJBcyXqKPCXK0mzb5QoyVEEqXzwCSx7XMGhq32zvsPp yS+EAIp3ssO+rZd9o8uw3ID6qMXVVjFJZeHmIuXl710imqu9uVDWmnb9usV0Igq/Jj3i I9EDDMSQdJlPc07j/sDjqNWy408bMRgmqlGFKR9f8PeFSdQeSzCg3V252d8igxp9aYPD 6Z2aIG0rSOpqQe2aLoL8I8sqmwRnj3OpyQvq4m2lHrIlaEzTrwa7wnbPDjI8cdlajjv4 sAwkq4tiXwYkcEMPrLdjSmpzax4h5nRmgHP/MF5qE0SUUKQRUXVyizPtl5skA8yqUGaA L82g== X-Gm-Message-State: AODbwcAQig1ITCy0M6qBIEitofLYMwRdUHw/OBSlmQdwgtKOCAGRDBAK xwtS3Tec9sYzyQ== X-Received: by 10.99.178.11 with SMTP id x11mr5250867pge.68.1495121693992; Thu, 18 May 2017 08:34:53 -0700 (PDT) Received: from 192.168.0.37 (ec2-52-192-197-227.ap-northeast-1.compute.amazonaws.com. [52.192.197.227]) by smtp.gmail.com with ESMTPSA id g10sm10574524pgn.35.2017.05.18.08.34.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 May 2017 08:34:53 -0700 (PDT) From: Wei Yongjun To: Saeed Mahameed , Matan Barak , Leon Romanovsky , Hadar Hen Zion Cc: Wei Yongjun , netdev@vger.kernel.org, linux-rdma@vger.kernel.org Subject: [PATCH net-next] net/mlx5e: Fix possible memory leak Date: Thu, 18 May 2017 15:34:41 +0000 Message-Id: <20170518153441.24398-1-weiyj.lk@gmail.com> X-Mailer: git-send-email 2.9.3 MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wei Yongjun 'encap_header' is malloced and should be freed before leaving from the error handling cases, otherwise it will cause memory leak. Fixes: 232c001398ae ("net/mlx5e: Add support to neighbour update flow") Signed-off-by: Wei Yongjun Reviewed-by: Yuval Shaia --- drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c index 11c27e4..a72ecbc 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c @@ -1404,8 +1404,8 @@ static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv, if (!(nud_state & NUD_VALID)) { neigh_event_send(n, NULL); - neigh_release(n); - return -EAGAIN; + err = -EAGAIN; + goto out; } err = mlx5_encap_alloc(priv->mdev, e->tunnel_type, @@ -1510,8 +1510,8 @@ static int mlx5e_create_encap_header_ipv6(struct mlx5e_priv *priv, if (!(nud_state & NUD_VALID)) { neigh_event_send(n, NULL); - neigh_release(n); - return -EAGAIN; + err = -EAGAIN; + goto out; } err = mlx5_encap_alloc(priv->mdev, e->tunnel_type,