All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Garzik <jgarzik@mandrakesoft.com>
To: Bartlomiej Zolnierkiewicz <dake@staszic.waw.pl>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Frank Davis <fdavis112@juno.com>,
	linux-kernel@vger.kernel.org, torvalds@transmeta.com
Subject: Re: [PATCH] Re: [test11-pre2] rrunner.c compiler error
Date: Fri, 10 Nov 2000 09:27:23 -0500	[thread overview]
Message-ID: <3A0C05CB.158C0FF5@mandrakesoft.com> (raw)
In-Reply-To: <Pine.LNX.4.21.0011101458350.5675-100000@tricky>

[-- Attachment #1: Type: text/plain, Size: 465 bytes --]

Blah.  Puke.  Ug.  Not your changes, Bart... which are ok, but
incomplete.

Here is the complete bugfix.  There are two places where error
conditions are not fully handled, and 'out_spin' can kfree(image),
saving some code.  The worst bug of the list... if the firmware
copy_from_user failed....  we still load firmware [ie. questionable
data] into EEPROM.

-- 
Jeff Garzik             |
Building 1024           | Would you like a Twinkie?
MandrakeSoft            |

[-- Attachment #2: rrunner.patch --]
[-- Type: text/plain, Size: 2185 bytes --]

Index: drivers/net/rrunner.c
===================================================================
RCS file: /cvsroot/gkernel/linux_2_4/drivers/net/rrunner.c,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 rrunner.c
--- drivers/net/rrunner.c	2000/11/10 02:09:10	1.1.1.4
+++ drivers/net/rrunner.c	2000/11/10 14:21:01
@@ -1550,36 +1550,29 @@
 
 	rrpriv = (struct rr_private *)dev->priv;
 
-
 	switch(cmd){
 	case SIOCRRGFW:
-		if (!capable(CAP_SYS_RAWIO)){
-			error = -EPERM;
-			goto out;
-		}
+		if (!capable(CAP_SYS_RAWIO))
+			return -EPERM;
 
 		image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
 		if (!image){
 			printk(KERN_ERR "%s: Unable to allocate memory "
 			       "for EEPROM image\n", dev->name);
-			error = -ENOMEM;
-			goto out;
+			return -ENOMEM;
 		}
 		
 		spin_lock(&rrpriv->lock);
 		
 		if (rrpriv->fw_running){
 			printk("%s: Firmware already running\n", dev->name);
-			kfree(image);
 			error = -EPERM;
 			goto out_spin;
 		}
 
 		i = rr_read_eeprom(rrpriv, 0, image, EEPROM_BYTES);
 		if (i != EEPROM_BYTES){
-			kfree(image);
-			printk(KERN_ERR "%s: Error reading EEPROM\n",
-			       dev->name);
+			printk(KERN_ERR "%s: Error reading EEPROM\n", dev->name);
 			error = -EFAULT;
 			goto out_spin;
 		}
@@ -1591,9 +1584,8 @@
 		return error;
 		
 	case SIOCRRPFW:
-		if (!capable(CAP_SYS_RAWIO)){
+		if (!capable(CAP_SYS_RAWIO))
 			return -EPERM;
-		}
 
 		image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
 		if (!image){
@@ -1604,18 +1596,21 @@
 
 		oldimage = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
 		if (!oldimage){
+			kfree(image);
 			printk(KERN_ERR "%s: Unable to allocate memory "
 			       "for old EEPROM image\n", dev->name);
 			return -ENOMEM;
 		}
 
 		error = copy_from_user(image, rq->ifr_data, EEPROM_BYTES);
-		if (error)
-			error = -EFAULT;
+		if (error) {
+			kfree(image);
+			kfree(oldimage);
+			return -EFAULT;
+		}
 
 		spin_lock(&rrpriv->lock);
 		if (rrpriv->fw_running){
-			kfree(image);
 			kfree(oldimage);
 			printk("%s: Firmware already running\n", dev->name);
 			error = -EPERM;
@@ -1652,6 +1647,7 @@
 	}
 
  out_spin:
+	kfree(image);
 	spin_unlock(&rrpriv->lock);
 	return error;
 }

      reply	other threads:[~2000-11-10 14:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-10  2:49 [test11-pre2] rrunner.c compiler error Frank Davis
2000-11-10  3:09 ` Alan Cox
2000-11-10 14:04   ` [PATCH] " Bartlomiej Zolnierkiewicz
2000-11-10 14:27     ` Jeff Garzik [this message]

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=3A0C05CB.158C0FF5@mandrakesoft.com \
    --to=jgarzik@mandrakesoft.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=dake@staszic.waw.pl \
    --cc=fdavis112@juno.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.