From patchwork Thu Oct 22 05:42:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dinghao Liu X-Patchwork-Id: 288212 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4E13C388F7 for ; Thu, 22 Oct 2020 05:42:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 67C6F206B6 for ; Thu, 22 Oct 2020 05:42:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2508000AbgJVFmt (ORCPT ); Thu, 22 Oct 2020 01:42:49 -0400 Received: from spam.zju.edu.cn ([61.164.42.155]:55330 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2437582AbgJVFms (ORCPT ); Thu, 22 Oct 2020 01:42:48 -0400 Received: from localhost.localdomain (unknown [210.32.148.79]) by mail-app2 (Coremail) with SMTP id by_KCgBXX+vKG5FfEIM4AA--.38547S4; Thu, 22 Oct 2020 13:42:37 +0800 (CST) From: Dinghao Liu To: dinghao.liu@zju.edu.cn, kjlu@umn.edu Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net-veth: Fix memleak in veth_newlink Date: Thu, 22 Oct 2020 13:42:33 +0800 Message-Id: <20201022054233.17326-1-dinghao.liu@zju.edu.cn> X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cSsGvfC2KfnxnUUI43ZEXa 7VU1eT5JUUUUU== X-CM-SenderInfo: qrrzjiaqtzq6lmxovvfxof0/1tbiAgABBlZdtQiRQQABsi Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When rtnl_configure_link() fails, peer needs to be freed just like when register_netdevice() fails. Signed-off-by: Dinghao Liu --- drivers/net/veth.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 8c737668008a..6c68094399cc 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -1405,8 +1405,6 @@ static int veth_newlink(struct net *src_net, struct net_device *dev, /* nothing to do */ err_configure_peer: unregister_netdevice(peer); - return err; - err_register_peer: free_netdev(peer); return err;