lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200818134404.63828-1-wanghai38@huawei.com>
Date:   Tue, 18 Aug 2020 21:44:04 +0800
From:   Wang Hai <wanghai38@...wei.com>
To:     <ulli.kroll@...glemail.com>, <linus.walleij@...aro.org>,
        <davem@...emloft.net>, <kuba@...nel.org>, <mirq-linux@...e.qmqm.pl>
CC:     <linux-arm-kernel@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>, <netdev@...r.kernel.org>
Subject: [PATCH net] net: gemini: Fix missing free_netdev() in error path of gemini_ethernet_port_probe()

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 <hulkci@...wei.com>
Signed-off-by: Wang Hai <wanghai38@...wei.com>
---
 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;
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ