[Devel,2/2] venet: do not leave destructor, if stats is NULL

Submitted by Stanislav Kinsburskiy on July 25, 2017, 8:39 a.m.

Details

Message ID 20170725083951.1832.94374.stgit@localhost.localdomain
State New
Series "venet: fix device leakage in destructor"
Headers show

Commit Message

Stanislav Kinsburskiy July 25, 2017, 8:39 a.m.
1) It can't happen
2) Device has to be freed anyways

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
---
 drivers/net/venetdev.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/net/venetdev.c b/drivers/net/venetdev.c
index 5ac62c5..5710792 100644
--- a/drivers/net/venetdev.c
+++ b/drivers/net/venetdev.c
@@ -458,15 +458,12 @@  EXPORT_SYMBOL(venet_free_stat);
 static void venet_destructor(struct net_device *dev)
 {
 	struct venet_stats *stats = (struct venet_stats *)dev->ml_priv;
-	if (stats == NULL)
-		return;
-	free_percpu(stats->real_stats);
-	kfree(stats);
-	dev->ml_priv = NULL;
 
 	if (venet_free_stat)
 		venet_free_stat(dev->nd_net->owner_ve);
 
+	free_percpu(stats->real_stats);
+	kfree(stats);
 	free_netdev(dev);
 }