public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Drokin <green@linuxhacker.ru>
To: marcelo@conectiva.com.br, linux-kernel@vger.kernel.org, matthew@wil.cx
Subject: [PATCH] [2.4] Fix possible memleaks in Ethtool ioctl handler
Date: Mon, 22 Sep 2003 01:19:52 +0400	[thread overview]
Message-ID: <20030921211952.GA5903@linuxhacker.ru> (raw)

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)

                 reply	other threads:[~2003-09-21 21:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030921211952.GA5903@linuxhacker.ru \
    --to=green@linuxhacker.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    --cc=matthew@wil.cx \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox