Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5694527pxu; Wed, 23 Dec 2020 03:09:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzw90w5G/vgVWWucRug5/h2mX0sW2QMNYGyoF0QQMIoP8+QJOo9ScAvTDkk5apoCe1MgIka X-Received: by 2002:a50:dacd:: with SMTP id s13mr24410769edj.173.1608721759346; Wed, 23 Dec 2020 03:09:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608721759; cv=none; d=google.com; s=arc-20160816; b=XxV5arfGhjN/DXJkk++aaid5DF505AH94JFnUnKpW0k2uGVxocldfMan5jSCTrqR94 rJb9Qjt5IEPTFv2u4jOMt16iju32xyY6EVrcz/Ki5iq1BcddpVZ0tf/8GmMeROEiKuUz wZKJcmy3+cB6zmfdrlXOZWfCR6JbbYGju1E/K/0JAJSlxSyXxPQN1wpbM2VncM0f52jo dcMUXcoALvFf6X40IiGa4llPIFVSB4cZcwl9fe7NCOsdXaxhU7IOJaRD2BLLl4oHDZmU ifFYEjOcACB+QAp88y6xexygrKPr2dXo3tPFMdZ/+apOER5xsR3WvkA/VO+nm8Nk2mNi pKUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=wio22mnOzvimVz1aTaZJIXIldHnUdOkf0O4n3Ac8QyQ=; b=BPcIuuFy9RMjAzY/fO9Fm1LnEPgNDXLi+I7dyFzqVO+wwFPkLRK2quSTJwOTGggaSh 7nKZeG+3iQ+Y50FYXfMgCQaD8pqei5ByQa5xXoFibCoM5Fgt06a/4o6IJxNHT1Ek29VU qqE1QeCG1WqYh/rG9dqFix2lHPdbbJHkaBwuU9aA3gp4ZhYyk/D3m7klAiRPezwa6542 RqazE4gJ7iBx6J7U1u8a3x4pO0RcvLqb+5Ifd6FFolYm9IgHfogtiHwRrHgTwJj9Kv3c K87bv90C5vsl7t9+m+nzvSkDfgh3ThybowEWIlmvsBquGkXI6ErinzHdE5Ze5+am+osb iPng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e14si13317152edy.505.2020.12.23.03.08.57; Wed, 23 Dec 2020 03:09:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728567AbgLWLHd (ORCPT + 99 others); Wed, 23 Dec 2020 06:07:33 -0500 Received: from mail.zju.edu.cn ([61.164.42.155]:28352 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728305AbgLWLHb (ORCPT ); Wed, 23 Dec 2020 06:07:31 -0500 Received: from localhost.localdomain (unknown [10.192.85.18]) by mail-app4 (Coremail) with SMTP id cS_KCgAHP3yhJONfjUsAAA--.469S4; Wed, 23 Dec 2020 19:06:13 +0800 (CST) From: Dinghao Liu To: dinghao.liu@zju.edu.cn, kjlu@umn.edu Cc: "David S. Miller" , Jakub Kicinski , Jesse Brandeburg , Arnd Bergmann , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: ethernet: Fix memleak in ethoc_probe Date: Wed, 23 Dec 2020 19:06:12 +0800 Message-Id: <20201223110615.31389-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cS_KCgAHP3yhJONfjUsAAA--.469S4 X-Coremail-Antispam: 1UD129KBjvdXoW7JFW8Ary5uFW3XFW5ur1kGrg_yoWDGFc_Kw 1IvrsYqr4rGF93Cw4UCr4UX34qkrs5Zr18Ars3KayYq3sxXF4UZrZ7Zrn3CF15Wr4IkF9F v3sFvr4xC342kjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbc8Fc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3wAFIxvE14AK wVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20x vE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4UJVW0owA2z4x0Y4vEx4A2 jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52 x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWU GwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI4 8JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxGrwCF04k20xvE74AGY7Cv 6cx26r4fKr1UJr1l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGw C20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48J MIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMI IF0xvE42xK8VAvwI8IcIk0rVWrJr0_WFyUJwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY 6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUoOJ5UUUUU X-CM-SenderInfo: qrrzjiaqtzq6lmxovvfxof0/1tbiAgkDBlZdtRp0WwARsU Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When mdiobus_register() fails, priv->mdio allocated by mdiobus_alloc() has not been freed, which leads to memleak. Signed-off-by: Dinghao Liu --- drivers/net/ethernet/ethoc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c index 0981fe9652e5..3d9b0b161e24 100644 --- a/drivers/net/ethernet/ethoc.c +++ b/drivers/net/ethernet/ethoc.c @@ -1211,7 +1211,7 @@ static int ethoc_probe(struct platform_device *pdev) ret = mdiobus_register(priv->mdio); if (ret) { dev_err(&netdev->dev, "failed to register MDIO bus\n"); - goto free2; + goto free3; } ret = ethoc_mdio_probe(netdev); @@ -1243,6 +1243,7 @@ static int ethoc_probe(struct platform_device *pdev) netif_napi_del(&priv->napi); error: mdiobus_unregister(priv->mdio); +free3: mdiobus_free(priv->mdio); free2: clk_disable_unprepare(priv->clk); -- 2.17.1