public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [2.4] Fix possible memleaks in Ethtool ioctl handler
@ 2003-09-21 21:19 Oleg Drokin
  0 siblings, 0 replies; only message in thread
From: Oleg Drokin @ 2003-09-21 21:19 UTC (permalink / raw)
  To: marcelo, linux-kernel, matthew

Hello!

   There are trivial memleaks in Ethtool ioctl handler, while not all that
   dangerous since only root can cause them (I presume), still
   trivial patch below is needed at least for the correctness sake.
   Please apply.

   Found with help of smatch.

===== net/core/ethtool.c 1.4 vs edited =====
--- 1.4/net/core/ethtool.c	Tue Sep  2 04:26:28 2003
+++ edited/net/core/ethtool.c	Mon Sep 22 01:17:14 2003
@@ -247,8 +247,10 @@
 	if (!data)
 		return -ENOMEM;
 
-	if (copy_from_user(data, useraddr + sizeof(eeprom), len))
-		return -EFAULT;
+	if (copy_from_user(data, useraddr + sizeof(eeprom), len)) {
+		ret = -EFAULT;
+		goto out;
+	}
 
 	ret = dev->ethtool_ops->get_eeprom(dev, &eeprom, data);
 	if (!ret)
@@ -287,8 +289,10 @@
 	if (!data)
 		return -ENOMEM;
 
-	if (copy_from_user(data, useraddr + sizeof(eeprom), len))
-		return -EFAULT;
+	if (copy_from_user(data, useraddr + sizeof(eeprom), len)) {
+		ret = -EFAULT;
+		goto out;
+	}
 
 	ret = dev->ethtool_ops->set_eeprom(dev, &eeprom, data);
 	if (ret)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-09-21 21:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-21 21:19 [PATCH] [2.4] Fix possible memleaks in Ethtool ioctl handler Oleg Drokin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox