From patchwork Tue Aug 18 13:44:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Hai X-Patchwork-Id: 11720925 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 81EAC14F6 for ; Tue, 18 Aug 2020 13:49:39 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5ABB0206DA for ; Tue, 18 Aug 2020 13:49:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ODraqyHg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5ABB0206DA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Ay93UNbXbIiziN14zSBHhyQKoPGx1kgJHEAvCZB0nP0=; b=ODraqyHgs9g+dBrs48wvCOBj7L ua7akx5FSzuxhsH47sYeptwrZVc0S0+AKkQrsg5RUYtZmgkCdhOFNQcbA9pIfTMeX2gIe2ZtHuwP1 IZ48cgAuwNM1oH3v/aPg6xkMM4ZdmkDn9wzuvpuiUtJ/ulixf3ObZ4DpFI2JMve/HxM/tu8BqABp1 f83puEfZEBc5nDKLdsZeKmn2aoNMWbM9O2hpRii3CYJ9JVAqDjgn9q9RIqlgCXpDTrVrbKt70rJJD tYiUsBIHLBLIDxDH5Dk45sarEreicGx9jVq/Ip2SZfP+rmQMqheFXUhKscE349BlH9KwVZjfcK3mz HeiGwNuA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k81ws-0006V3-WF; Tue, 18 Aug 2020 13:46:47 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35] helo=huawei.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k81wq-0006Tx-9s for linux-arm-kernel@lists.infradead.org; Tue, 18 Aug 2020 13:46:45 +0000 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A46A2698D4DD69BE3844; Tue, 18 Aug 2020 21:46:16 +0800 (CST) Received: from huawei.com (10.175.113.133) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Tue, 18 Aug 2020 21:46:11 +0800 From: Wang Hai To: , , , , Subject: [PATCH net] net: gemini: Fix missing free_netdev() in error path of gemini_ethernet_port_probe() Date: Tue, 18 Aug 2020 21:44:04 +0800 Message-ID: <20200818134404.63828-1-wanghai38@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.175.113.133] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200818_094644_592911_0BC1F243 X-CRM114-Status: GOOD ( 12.39 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.35 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [45.249.212.35 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Fix the missing free_netdev() before return from gemini_ethernet_port_probe() in the error handling case. Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet") Reported-by: Hulk Robot Signed-off-by: Wang Hai --- drivers/net/ethernet/cortina/gemini.c | 35 ++++++++++++++++++--------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index 66e67b24a887..d8de50fde27d 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -2407,37 +2407,46 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev) dmares = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!dmares) { dev_err(dev, "no DMA resource\n"); - return -ENODEV; + ret = -ENODEV; + goto err_out_free; } port->dma_base = devm_ioremap_resource(dev, dmares); - if (IS_ERR(port->dma_base)) - return PTR_ERR(port->dma_base); + if (IS_ERR(port->dma_base)) { + ret = PTR_ERR(port->dma_base); + goto err_out_free; + } /* GMAC config memory */ gmacres = platform_get_resource(pdev, IORESOURCE_MEM, 1); if (!gmacres) { dev_err(dev, "no GMAC resource\n"); - return -ENODEV; + ret = -ENODEV; + goto err_out_free; } port->gmac_base = devm_ioremap_resource(dev, gmacres); - if (IS_ERR(port->gmac_base)) - return PTR_ERR(port->gmac_base); + if (IS_ERR(port->gmac_base)) { + ret = PTR_ERR(port->gmac_base); + goto err_out_free; + } /* Interrupt */ irq = platform_get_irq(pdev, 0); - if (irq <= 0) - return irq ? irq : -ENODEV; + if (irq <= 0) { + ret = irq ? irq : -ENODEV; + goto err_out_free; + } port->irq = irq; /* Clock the port */ port->pclk = devm_clk_get(dev, "PCLK"); if (IS_ERR(port->pclk)) { dev_err(dev, "no PCLK\n"); - return PTR_ERR(port->pclk); + ret = PTR_ERR(port->pclk); + goto err_out_free; } ret = clk_prepare_enable(port->pclk); if (ret) - return ret; + goto err_out_free; /* Maybe there is a nice ethernet address we should use */ gemini_port_save_mac_addr(port); @@ -2447,7 +2456,8 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev) if (IS_ERR(port->reset)) { dev_err(dev, "no reset\n"); clk_disable_unprepare(port->pclk); - return PTR_ERR(port->reset); + ret = PTR_ERR(port->reset); + goto err_out_free; } reset_control_reset(port->reset); usleep_range(100, 500); @@ -2504,7 +2514,7 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev) port); if (ret) { clk_disable_unprepare(port->pclk); - return ret; + goto err_out_free; } ret = register_netdev(netdev); @@ -2520,6 +2530,7 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev) return 0; } +err_out_free: port->netdev = NULL; free_netdev(netdev); return ret;