mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Fix mem leak in intel_sdvo_write_cmd()
@ 2012-07-31 20:31 Jesper Juhl
  2012-08-05 21:00 ` Daniel Vetter
  0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2012-07-31 20:31 UTC (permalink / raw)
  To: David Airlie; +Cc: Daniel Vetter, Jesse Barnes, dri-devel, linux-kernel

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@chaosbits.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@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/i915: Fix mem leak in intel_sdvo_write_cmd()
  2012-07-31 20:31 [PATCH] drm/i915: Fix mem leak in intel_sdvo_write_cmd() Jesper Juhl
@ 2012-08-05 21:00 ` Daniel Vetter
  2012-08-05 21:19   ` Jesper Juhl
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Vetter @ 2012-08-05 21:00 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: David Airlie, Daniel Vetter, Jesse Barnes, linux-kernel, dri-devel

On Tue, Jul 31, 2012 at 10:31:15PM +0200, Jesper Juhl wrote:
> 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@chaosbits.net>

I've already merged a similar patch from Alan Cox for -fixes, should land
in 3.6 soonish.
-Daniel
-- 
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/i915: Fix mem leak in intel_sdvo_write_cmd()
  2012-08-05 21:00 ` Daniel Vetter
@ 2012-08-05 21:19   ` Jesper Juhl
  0 siblings, 0 replies; 3+ messages in thread
From: Jesper Juhl @ 2012-08-05 21:19 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: David Airlie, Daniel Vetter, Jesse Barnes, linux-kernel, dri-devel

On Sun, 5 Aug 2012, Daniel Vetter wrote:

> On Tue, Jul 31, 2012 at 10:31:15PM +0200, Jesper Juhl wrote:
> > 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@chaosbits.net>
> 
> I've already merged a similar patch from Alan Cox for -fixes, should land
> in 3.6 soonish.

Perfect.

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-08-05 21:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-31 20:31 [PATCH] drm/i915: Fix mem leak in intel_sdvo_write_cmd() Jesper Juhl
2012-08-05 21:00 ` Daniel Vetter
2012-08-05 21:19   ` Jesper Juhl

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

all inboxes | Powered by JetHome®