public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephane Eranian <eranian@frankl.hpl.hp.com>
To: linux-ia64@vger.kernel.org
Subject: Re: [Linux-ia64] [PATCH] pfm_smpl_buffer_alloc needs to free vma on error
Date: Fri, 30 Aug 2002 02:12:40 +0000	[thread overview]
Message-ID: <marc-linux-ia64-105590701906000@msgid-missing> (raw)
In-Reply-To: <marc-linux-ia64-105590701905999@msgid-missing>

[-- Attachment #1: Type: text/plain, Size: 500 bytes --]

On Fri, Aug 30, 2002 at 11:33:17AM +1000, Kingsley Cheung wrote:
> Hi David,
> 
> In 2.4.19, arch/ia64/kernel/perfmon.c, I noticed that 
> pfm_smpl_buffer_alloc doesn't seem to be freeing the vma structure it 
> allocates if there's an error.  Here's a trivial patch to fix it:
> 
Yes, you are right. I have generated a similar patch with the labels slightly 
renamed.  Note that the patch also fixes another problem with read_unlock()
in the same function.

Thanks for spotting this.

--
-Stephane


[-- Attachment #2: perfmon-020829 --]
[-- Type: text/plain, Size: 1091 bytes --]

--- linux.2419/arch/ia64/kernel/perfmon.c.old	Wed Aug 28 12:14:22 2002
+++ linux.2419/arch/ia64/kernel/perfmon.c	Thu Aug 29 19:08:02 2002
@@ -767,15 +767,14 @@
 	psb = kmalloc(sizeof(*psb), GFP_KERNEL);
 	if (psb == NULL) {
 		DBprintk(("Can't allocate sampling buffer descriptor\n"));
-		pfm_rvfree(smpl_buf, size);
-		return -ENOMEM;
+		goto error_kmalloc;
 	}
 
 	/* allocate vma */
 	vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
 	if (!vma) {
 		DBprintk(("Cannot allocate vma\n"));
-		goto error;
+		goto error_kmem;
 	}
 	/*
 	 * partially initialize the vma for the sampling buffer
@@ -875,8 +874,11 @@
 	return 0;
 
 error:
-	pfm_rvfree(smpl_buf, size);
+	kmem_cache_free(vm_area_cachep, vma);
+error_kmem:
 	kfree(psb);
+error_kmalloc:
+	pfm_rvfree(smpl_buf, size);
 	return -ENOMEM;
 }
 
@@ -1057,7 +1059,10 @@
 			/*
 			 * check if we can send this task a signal
 			 */
-			if (pfm_bad_permissions(notify_task)) goto buffer_error;
+			if (pfm_bad_permissions(notify_task)) {
+				read_unlock(&tasklist_lock);
+				goto buffer_error;
+			}
 
 			/* 
 		 	 * make visible

      reply	other threads:[~2002-08-30  2:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-30  1:33 [Linux-ia64] [PATCH] pfm_smpl_buffer_alloc needs to free vma on error Kingsley Cheung
2002-08-30  2:12 ` Stephane Eranian [this message]

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=marc-linux-ia64-105590701906000@msgid-missing \
    --to=eranian@frankl.hpl.hp.com \
    --cc=linux-ia64@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