Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1606153

[PATCH 1/2] resource: Copy the whole res in resource_list_create_entry

From Jeffy Chen <jeffy.chen@rock-chips.com>
Newsgroups linux.kernel
Subject [PATCH 1/2] resource: Copy the whole res in resource_list_create_entry
Date 2017-03-22 03:30 +0100
Message-ID <tnEc9-3QK-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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@rock-chips.com>
---

 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

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] resource: Copy the whole res in resource_list_create_entry Jeffy Chen <jeffy.chen@rock-chips.com> - 2017-03-22 03:30 +0100
  [PATCH 2/2] of/pci: Fix memory leak in of_pci_get_host_bridge_resources Jeffy Chen <jeffy.chen@rock-chips.com> - 2017-03-22 03:30 +0100
    Re: [PATCH 2/2] of/pci: Fix memory leak in of_pci_get_host_bridge_resources Rob Herring <robh@kernel.org> - 2017-03-22 15:50 +0100
      Re: [PATCH 2/2] of/pci: Fix memory leak in of_pci_get_host_bridge_resources Rob Herring <robh@kernel.org> - 2017-03-22 16:00 +0100
        Re: [PATCH 2/2] of/pci: Fix memory leak in of_pci_get_host_bridge_resources jeffy <jeffy.chen@rock-chips.com> - 2017-03-23 09:30 +0100

csiph-web