[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1456323918-27487-1-git-send-email-simon.guinot@sequanux.org>
Date: Wed, 24 Feb 2016 15:25:18 +0100
From: Simon Guinot <simon.guinot@...uanux.org>
To: Jesse Barnes <jbarnes@...tuousgeek.org>,
Alan Cox <alan@...ux.intel.com>
Cc: Vincent Pelletier <plr.vincent@...il.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Giel van Schijndel <me@...tis.eu>,
Vincent Donnefort <vdonnefort@...il.com>,
Yoann Sculo <yoann@...lo.fr>,
Linus Walleij <linus.walleij@...aro.org>,
linux-kernel@...r.kernel.org,
Simon Guinot <simon.guinot@...uanux.org>,
stable@...r.kernel.org
Subject: [PATCH] kernel/resource.c: ensure parent is not freed in __request_region()
The commit 59ceeaaf355fa0fb16558ef7c24413c804932ada
("kernel/resource.c: fix muxed resource handling in __request_region()")
don't address properly the case where the current parent resource has
been freed while sleeping, waiting for a muxed resource to be available.
This patch fixes the issue by resetting the parent pointer to the root
parent resource when sleeping is needed.
Signed-off-by: Simon Guinot <simon.guinot@...uanux.org>
Cc: stable@...r.kernel.org
---
kernel/resource.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/resource.c b/kernel/resource.c
index 3669d1bfc425..14a7f9d66259 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -1052,16 +1052,17 @@ static DECLARE_WAIT_QUEUE_HEAD(muxed_resource_wait);
/**
* __request_region - create a new busy resource region
- * @parent: parent resource descriptor
+ * @root: root resource descriptor
* @start: resource start address
* @n: resource region size
* @name: reserving caller's ID string
* @flags: IO resource flags
*/
-struct resource * __request_region(struct resource *parent,
+struct resource * __request_region(struct resource *root,
resource_size_t start, resource_size_t n,
const char *name, int flags)
{
+ struct resource *parent = root;
DECLARE_WAITQUEUE(wait, current);
struct resource *res = alloc_resource(GFP_KERNEL);
@@ -1089,6 +1090,7 @@ struct resource * __request_region(struct resource *parent,
}
}
if (conflict->flags & flags & IORESOURCE_MUXED) {
+ parent = root;
add_wait_queue(&muxed_resource_wait, &wait);
write_unlock(&resource_lock);
set_current_state(TASK_UNINTERRUPTIBLE);
--
2.1.4
Powered by blists - more mailing lists