All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: xen-devel@lists.xensource.com, linux-kernel@vger.kernel.org
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH 8/9] xen/time: Check that the per_cpu data structure has data before freeing.
Date: Wed, 5 Jun 2013 08:54:37 -0700 (PDT)	[thread overview]
Message-ID: <1370447678-22367-9-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1370447678-22367-1-git-send-email-konrad.wilk@oracle.com>

We don't check whether the per_cpu data structure has actually
been freed in the past. This checks it and if it has been freed
in the past then just continues on without double-freeing.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 arch/x86/xen/time.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 011f1bf..6a56ae0 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -434,10 +434,13 @@ void xen_teardown_timer(int cpu)
 	struct clock_event_device *evt;
 	BUG_ON(cpu == 0);
 	evt = &per_cpu(xen_clock_events, cpu).evt;
-	unbind_from_irqhandler(evt->irq, NULL);
-	evt->irq = -1;
-	kfree(per_cpu(xen_clock_events, cpu).name);
-	per_cpu(xen_clock_events, cpu).name = NULL;
+
+	if (evt->irq >= 0) {
+		unbind_from_irqhandler(evt->irq, NULL);
+		evt->irq = -1;
+		kfree(per_cpu(xen_clock_events, cpu).name);
+		per_cpu(xen_clock_events, cpu).name = NULL;
+	}
 }
 
 void xen_setup_cpu_clockevents(void)
-- 
1.8.1.4


  parent reply	other threads:[~2013-06-05 15:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-05 15:54 [PATCH] fix kmemleak complaining about memory leaks when offlining/onlining vCPUS (v1) Konrad Rzeszutek Wilk
2013-06-05 15:54 ` [PATCH 1/9] xen/smp: Coalesce the free_irq calls in one function Konrad Rzeszutek Wilk
2013-06-05 15:54 ` [PATCH 2/9] xen/smp: Introduce a common structure to contain the IRQ name and interrupt line Konrad Rzeszutek Wilk
2013-06-06  7:16   ` Jan Beulich
2013-06-06  7:16   ` [Xen-devel] " Jan Beulich
2013-06-06 18:58     ` Konrad Rzeszutek Wilk
2013-06-06 18:58     ` [Xen-devel] " Konrad Rzeszutek Wilk
2013-06-05 15:54 ` [PATCH 3/9] xen/smp: Set the per-cpu IRQ number to a valid default Konrad Rzeszutek Wilk
2013-06-05 15:54 ` [PATCH 4/9] xen/smp: Don't leak interrupt name when offlining Konrad Rzeszutek Wilk
2013-06-05 15:54 ` [PATCH 5/9] xen/spinlock: " Konrad Rzeszutek Wilk
2013-06-05 15:54 ` [PATCH 6/9] xen/time: Encapsulate the struct clock_event_device in another structure Konrad Rzeszutek Wilk
2013-06-05 15:54 ` [PATCH 7/9] xen/time: Don't leak interrupt name when offlining Konrad Rzeszutek Wilk
2013-06-05 15:54 ` Konrad Rzeszutek Wilk [this message]
2013-06-05 15:54 ` [PATCH 9/9] xen/time: Free onlined per-cpu data structure if we want to online it again Konrad Rzeszutek Wilk

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=1370447678-22367-9-git-send-email-konrad.wilk@oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.