From: Jeffy Chen <jeffy.chen@rock-chips.com>
To: linux-kernel@vger.kernel.org
Cc: robh@kernel.org, toshi.kani@hpe.com, shawn.lin@rock-chips.com,
briannorris@chromium.org, dianders@chromium.org,
bhelgaas@google.com, dtor@chromium.org,
Jeffy Chen <jeffy.chen@rock-chips.com>
Subject: [PATCH 1/2] resource: Copy the whole res in resource_list_create_entry
Date: Wed, 22 Mar 2017 10:25:45 +0800 [thread overview]
Message-ID: <1490149546-4062-1-git-send-email-jeffy.chen@rock-chips.com> (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
next reply other threads:[~2017-03-22 2:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-22 2:25 Jeffy Chen [this message]
2017-03-22 2:25 ` [PATCH 2/2] of/pci: Fix memory leak in of_pci_get_host_bridge_resources Jeffy Chen
2017-03-22 14:39 ` Rob Herring
2017-03-22 14:55 ` Rob Herring
2017-03-23 8:22 ` jeffy
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=1490149546-4062-1-git-send-email-jeffy.chen@rock-chips.com \
--to=jeffy.chen@rock-chips.com \
--cc=bhelgaas@google.com \
--cc=briannorris@chromium.org \
--cc=dianders@chromium.org \
--cc=dtor@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=shawn.lin@rock-chips.com \
--cc=toshi.kani@hpe.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).