lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <alpine.LNX.2.00.1108020004250.31999@swampdragon.chaosbits.net>
Date:	Tue, 2 Aug 2011 00:07:06 +0200 (CEST)
From:	Jesper Juhl <jj@...osbits.net>
To:	linux-kernel@...r.kernel.org
cc:	Tiago Vignatti <vignatti@...edesktop.org>,
	"Paulo R. Zanoni" <przanoni@...il.com>,
	Benjamin Herrenschmidt <benh@...nel.crashing.org>,
	Dave Airlie <airlied@...hat.com>,
	Lucas De Marchi <lucas.demarchi@...fusion.mobi>,
	Chris Wilson <chris@...is-wilson.co.uk>,
	Alex Deucher <alexdeucher@...il.com>,
	Daniel J Blueman <daniel.blueman@...il.com>
Subject: [PATCH][Resend] vga: Fix mem leaks in vga_arb_write()

We don't always free the memory allocated to 'kbuf' - make sure we do
so.
Also, while I was there anyway, remove a unneeded kfree call and
instead just set ret_val and fall through to the 'done' label.
I also made a small trivial change to a comment and a small whitespace
correction in an assignment.

Signed-off-by: Jesper Juhl <jj@...osbits.net>
---
 drivers/gpu/vga/vgaarb.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
index c72f1c0..63c7d49 100644
--- a/drivers/gpu/vga/vgaarb.c
+++ b/drivers/gpu/vga/vgaarb.c
@@ -993,14 +993,15 @@ static ssize_t vga_arb_write(struct file *file, const char __user * buf,
 				uc = &priv->cards[i];
 		}
 
+		ret_val = -EINVAL;
 		if (!uc)
-			return -EINVAL;
+			goto done;
 
 		if (io_state & VGA_RSRC_LEGACY_IO && uc->io_cnt == 0)
-			return -EINVAL;
+			goto done;
 
 		if (io_state & VGA_RSRC_LEGACY_MEM && uc->mem_cnt == 0)
-			return -EINVAL;
+			goto done;
 
 		vga_put(pdev, io_state);
 
@@ -1115,7 +1116,7 @@ static ssize_t vga_arb_write(struct file *file, const char __user * buf,
 				MAX_USER_CARDS);
 			pci_dev_put(pdev);
 			/* XXX: which value to return? */
-			ret_val =  -ENOMEM;
+			ret_val = -ENOMEM;
 			goto done;
 		}
 
@@ -1143,10 +1144,8 @@ static ssize_t vga_arb_write(struct file *file, const char __user * buf,
 		ret_val = count;
 		goto done;
 	}
-	/* If we got here, the message written is not part of the protocol! */
-	kfree(kbuf);
-	return -EPROTO;
-
+	/* If we get here, the message written is not part of the protocol! */
+	ret_val = -EPROTO;
 done:
 	kfree(kbuf);
 	return ret_val;
-- 
1.7.6


-- 
Jesper Juhl <jj@...osbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ