lkml.org 
[lkml]   [2021]   [Jun]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] net: ethernet: fix UAF in ltq_etop_init
Date
In ltq_etop_init() netdev was used after free_netdev():

err_netdev:
unregister_netdev(dev);
free_netdev(dev);
err_hw:
ltq_etop_hw_exit(dev);
return err;

It causes use-after-free read/write in ltq_etop_hw_exit().
Fix it by rewriting error handling path in this function. No logic
changes, only small refactoring.

Fixes: ("MIPS: Lantiq: Add ethernet driver")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
drivers/net/ethernet/lantiq_etop.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
index 2d0c52f7106b..807a671ebcf8 100644
--- a/drivers/net/ethernet/lantiq_etop.c
+++ b/drivers/net/ethernet/lantiq_etop.c
@@ -553,8 +553,10 @@ ltq_etop_init(struct net_device *dev)

dev->watchdog_timeo = 10 * HZ;
err = ltq_etop_hw_init(dev);
- if (err)
- goto err_hw;
+ if (err) {
+ ltq_etop_hw_exit(dev);
+ return err;
+ }
ltq_etop_change_mtu(dev, 1500);

memcpy(&mac, &priv->pldata->mac, sizeof(struct sockaddr));
@@ -580,9 +582,8 @@ ltq_etop_init(struct net_device *dev)

err_netdev:
unregister_netdev(dev);
- free_netdev(dev);
-err_hw:
ltq_etop_hw_exit(dev);
+ free_netdev(dev);
return err;
}

--
2.32.0
\
 
 \ /
  Last update: 2021-06-25 23:27    [W:0.035 / U:0.668 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site