mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Andre Bartke <andre.bartke@googlemail.com>
Cc: gregkh@suse.de, devel@driverdev.osuosl.org,
	Andre Bartke <andre.bartke@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: intel_sst: Fix memory leak
Date: Wed, 1 Jun 2011 01:42:12 +0300	[thread overview]
Message-ID: <20110531224212.GC3661@shale.localdomain> (raw)
In-Reply-To: <1306868636-23367-1-git-send-email-andre.bartke@gmail.com>

On Tue, May 31, 2011 at 09:03:56PM +0200, Andre Bartke wrote:
> In case of an error stream_bufs is not freed here.
> 
> Signed-off-by: Andre Bartke <andre.bartke@gmail.com>
> ---
>  .../staging/intel_sst/intel_sst_app_interface.c    |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/staging/intel_sst/intel_sst_app_interface.c b/drivers/staging/intel_sst/intel_sst_app_interface.c
> index b8c7ddb..93b41a2 100644
> --- a/drivers/staging/intel_sst/intel_sst_app_interface.c
> +++ b/drivers/staging/intel_sst/intel_sst_app_interface.c
> @@ -430,8 +430,10 @@ static int snd_sst_fill_kernel_list(struct stream_info *stream,
>  				return -ENOMEM;
>  			if (copy_from_user((void *) &rar_handle,
>  					iovec[index].iov_base,
> -					sizeof(__u32)))
> +					sizeof(__u32))) {
> +				kfree(stream_bufs);
>  				return -EFAULT;
> +			}
>  			stream_bufs->addr = (char *)rar_handle;


Btw, the original code looks seems pretty awful.  "rar_handle" is
a kernel pointer that we get from user space.  It is a u32 type so
this won't work under a 64 bit OS.

These allocations get added to a list.  Maybe we should free them
all?  It's hard to say.  There is only one place that calls this
function, and it ignores the return value.

regards,
dan carpenter

  reply	other threads:[~2011-05-31 22:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-31 19:03 Andre Bartke
2011-05-31 22:42 ` Dan Carpenter [this message]
2011-06-01 12:50 ` Alan Cox

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=20110531224212.GC3661@shale.localdomain \
    --to=error27@gmail.com \
    --cc=andre.bartke@gmail.com \
    --cc=andre.bartke@googlemail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@suse.de \
    --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®