mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "devendra.aaru" <devendra.aaru@gmail.com>
To: Jesper Juhl <jj@chaosbits.net>
Cc: Dave Airlie <airlied@redhat.com>, David Airlie <airlied@linux.ie>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mgag200: Fix a memory leak in mgag200fb_create()
Date: Fri, 22 Jun 2012 13:30:58 +0530	[thread overview]
Message-ID: <CAHdPZaMCDO2GAyxR_WYxqpwC1Ym307uj3CXFG7r0LybMLH7Pig@mail.gmail.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1206220012470.7671@swampdragon.chaosbits.net>

On Fri, Jun 22, 2012 at 3:43 AM, Jesper Juhl <jj@chaosbits.net> wrote:
> First we allocate memory for 'sysram' with vmalloc() and subsequently
> we allocate for 'info' with framebuffer_alloc(). If the second
> allocation fails we return -ENOMEM, but neglect to vfree() the memory
> we previously allocated for 'sysram', thus leaking it.
>
Hi Jesper,

> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
>  drivers/gpu/drm/mgag200/mgag200_fb.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c
> index 880d336..3c837e5 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_fb.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
> @@ -156,8 +156,10 @@ static int mgag200fb_create(struct mga_fbdev *mfbdev,
>                return -ENOMEM;
>
>        info = framebuffer_alloc(0, device);
> -       if (info == NULL)
> +       if (info == NULL) {
> +               vfree(sysram);
>                return -ENOMEM;
> +       }
>
>        info->par = mfbdev;
>
This looks ok. but what about the error path?
there are more leaks at error paths. mgag200_framebuffer_init failcase
and the functions below like,
fb_alloc_cmap,
alloc_apertures,
?

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

  reply	other threads:[~2012-06-22  8:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-21 22:13 Jesper Juhl
2012-06-22  8:00 ` devendra.aaru [this message]
2012-06-24 18:28   ` Jesper Juhl

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=CAHdPZaMCDO2GAyxR_WYxqpwC1Ym307uj3CXFG7r0LybMLH7Pig@mail.gmail.com \
    --to=devendra.aaru@gmail.com \
    --cc=airlied@linux.ie \
    --cc=airlied@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jj@chaosbits.net \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®