[PATCH 1/2] resource: Copy the whole res in resource_list_create_entry
From: Jeffy Chen
Date: Tue Mar 21 2017 - 22:26:14 EST
We do this so the callers may not need worry about when to free the
allocated resource struct.
Signed-off-by: Jeffy Chen <jeffy.chen@xxxxxxxxxxxxxx>
---
kernel/resource.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/resource.c b/kernel/resource.c
index 9b5f044..f3594f8 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -1595,7 +1595,9 @@ struct resource_entry *resource_list_create_entry(struct resource *res,
entry = kzalloc(sizeof(*entry) + extra_size, GFP_KERNEL);
if (entry) {
INIT_LIST_HEAD(&entry->node);
- entry->res = res ? res : &entry->__res;
+ entry->res = &entry->__res;
+ if (res)
+ entry->__res = *res;
}
return entry;
--
2.1.4