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>] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LNX.2.00.1207312228270.7100@swampdragon.chaosbits.net>
Date:	Tue, 31 Jul 2012 22:31:15 +0200 (CEST)
From:	Jesper Juhl <jj@...osbits.net>
To:	David Airlie <airlied@...ux.ie>
cc:	Daniel Vetter <daniel.vetter@...ll.ch>,
	Jesse Barnes <jesse.barnes@...el.com>,
	dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: [PATCH] drm/i915: Fix mem leak in intel_sdvo_write_cmd()

If the allocation of 'buf' succeeds but the allocation of 'msgs' fails
we'll return false and leak 'buf' when it goes out of scope.

Signed-off-by: Jesper Juhl <jj@...osbits.net>
---
 drivers/gpu/drm/i915/intel_sdvo.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

 note: compile tested only due to lack of hardware.

diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 26a6a4d..1f73e24 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -444,13 +444,12 @@ static bool intel_sdvo_write_cmd(struct intel_sdvo *intel_sdvo, u8 cmd,
 	struct i2c_msg *msgs;
 	int i, ret = true;
 
-	buf = (u8 *)kzalloc(args_len * 2 + 2, GFP_KERNEL);
-	if (!buf)
-		return false;
-
+	buf = kzalloc(args_len * 2 + 2, GFP_KERNEL);
 	msgs = kcalloc(args_len + 3, sizeof(*msgs), GFP_KERNEL);
-	if (!msgs)
-		return false;
+	if (!msgs || !buf) {
+		ret = false;
+		goto out;
+	}
 
 	intel_sdvo_debug_write(intel_sdvo, cmd, args, args_len);
 
-- 
1.7.11.3


-- 
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