From: Nathan Fontenot <nfont@linux.vnet.ibm.com>
To: "linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Cc: andriy.shevchenko@linux.intel.com
Subject: [PATCH] powerpc/pseries: Correct string length in pseries_of_derive_parent()
Date: Mon, 26 Oct 2015 14:33:05 -0500 [thread overview]
Message-ID: <562E7FF1.1040806@linux.vnet.ibm.com> (raw)
Commit a030e1e4bbd085bbcfd0a23f8d355fcd41f39bed made a change to use
kstrndup() instead of kmalloc() + strlcpy() in pseries_of_derive_parent()
which introduces a subtle change in the parent path name generated.
The kstrndup() routine will copy n characters followed by a terminating null,
whereas strlcpy() will copy n-1 characters and add a terminating null.
This slight difference results in having a parent path that includes the
trailing '/' character, i.e. "/cpus/" vs. "/cpus". This then causes the
subsequent call to of_find_node_by_path() to fail, and in the case of
DLPAR add operations, the DLPAR request fails.
This patch reduces the total length of the string to copy in kstrndup by 1
so we no longer copy the trailing '/'.
Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
arch/powerpc/platforms/pseries/of_helpers.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/pseries/of_helpers.c b/arch/powerpc/platforms/pseries/of_helpers.c
index 4417afe..6d90378 100644
--- a/arch/powerpc/platforms/pseries/of_helpers.c
+++ b/arch/powerpc/platforms/pseries/of_helpers.c
@@ -24,7 +24,7 @@ struct device_node *pseries_of_derive_parent(const char *path)
return ERR_PTR(-EINVAL);
if (tail > path + 1) {
- parent_path = kstrndup(path, tail - path, GFP_KERNEL);
+ parent_path = kstrndup(path, (tail - 1) - path, GFP_KERNEL);
if (!parent_path)
return ERR_PTR(-ENOMEM);
}
next reply other threads:[~2015-10-26 19:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-26 19:33 Nathan Fontenot [this message]
2015-10-27 8:17 ` [PATCH] powerpc/pseries: Correct string length in pseries_of_derive_parent() Andy Shevchenko
2015-10-27 13:51 ` Nathan Fontenot
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=562E7FF1.1040806@linux.vnet.ibm.com \
--to=nfont@linux.vnet.ibm.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linuxppc-dev@lists.ozlabs.org \
/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).