linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tyrel Datwyler <tyreld@linux.ibm.com>
To: mpe@ellerman.id.au
Cc: benh@kernel.crashing.org, linuxppc-dev@lists.ozlabs.org,
	tlfalcon@linux.ibm.com, nathanl@linux.ibm.com,
	bhelgaas@google.com, linux-pci@vger.kernel.org,
	Tyrel Datwyler <tyreld@linux.ibm.com>
Subject: [PATCH v2 1/9] powerpc/pseries: Fix bad drc_index_start value parsing of drc-info entry
Date: Sun, 10 Nov 2019 23:21:28 -0600	[thread overview]
Message-ID: <1573449697-5448-2-git-send-email-tyreld@linux.ibm.com> (raw)
In-Reply-To: <1573449697-5448-1-git-send-email-tyreld@linux.ibm.com>

The ibm,drc-info property is an array property that contains drc-info
entries such that each entry is made up of 2 string encoded elements
followed by 5 int encoded elements. The of_read_drc_info_cell()
helper contains comments that correctly name the expected elements
and their encoding. However, the usage of of_prop_next_string() and
of_prop_next_u32() introduced a subtle skippage of the first u32.
This is a result of of_prop_next_string() returning a pointer to the
next property value which is not a string, but actually a (__be32 *).
As, a result the following call to of_prop_next_u32() passes over the
current int encoded value and actually stores the next one wrongly.

Simply endian swap the current value in place after reading the first
two string values. The remaining int encoded values can then be read
correctly using of_prop_next_u32().

Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com>
---
 arch/powerpc/platforms/pseries/of_helpers.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/of_helpers.c b/arch/powerpc/platforms/pseries/of_helpers.c
index 6df192f..66dfd82 100644
--- a/arch/powerpc/platforms/pseries/of_helpers.c
+++ b/arch/powerpc/platforms/pseries/of_helpers.c
@@ -45,14 +45,14 @@ struct device_node *pseries_of_derive_parent(const char *path)
 int of_read_drc_info_cell(struct property **prop, const __be32 **curval,
 			struct of_drc_info *data)
 {
-	const char *p;
+	const char *p = (char *)(*curval);
 	const __be32 *p2;
 
 	if (!data)
 		return -EINVAL;
 
 	/* Get drc-type:encode-string */
-	p = data->drc_type = (char*) (*curval);
+	data->drc_type = (char *)p;
 	p = of_prop_next_string(*prop, p);
 	if (!p)
 		return -EINVAL;
@@ -65,9 +65,7 @@ int of_read_drc_info_cell(struct property **prop, const __be32 **curval,
 
 	/* Get drc-index-start:encode-int */
 	p2 = (const __be32 *)p;
-	p2 = of_prop_next_u32(*prop, p2, &data->drc_index_start);
-	if (!p2)
-		return -EINVAL;
+	data->drc_index_start = be32_to_cpu(*p2);
 
 	/* Get drc-name-suffix-start:encode-int */
 	p2 = of_prop_next_u32(*prop, p2, &data->drc_name_suffix_start);
-- 
2.7.4


  reply	other threads:[~2019-11-11  5:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-11  5:21 [PATCH v2 0/9] Fixes and Enablement of ibm,drc-info property Tyrel Datwyler
2019-11-11  5:21 ` Tyrel Datwyler [this message]
2019-11-14  9:08   ` [PATCH v2 1/9] powerpc/pseries: Fix bad drc_index_start value parsing of drc-info entry Michael Ellerman
2019-11-11  5:21 ` [PATCH v2 2/9] powerpc/pseries: Fix drc-info mappings of logical cpus to drc-index Tyrel Datwyler
2019-11-11  5:21 ` [PATCH v2 3/9] powerpc/pseries: Add cpu DLPAR support for drc-info property Tyrel Datwyler
2019-11-11  5:21 ` [PATCH v2 4/9] PCI: rpaphp: Fix up pointer to first drc-info entry Tyrel Datwyler
2019-11-11  5:21 ` [PATCH v2 5/9] PCI: rpaphp: Don't rely on firmware feature to imply drc-info support Tyrel Datwyler
2019-11-11  5:21 ` [PATCH v2 6/9] PCI: rpaphp: Add drc-info support for hotplug slot registration Tyrel Datwyler
2019-11-11  5:21 ` [PATCH v2 7/9] PCI: rpaphp: annotate and correctly byte swap DRC properties Tyrel Datwyler
2019-11-11  5:21 ` [PATCH v2 7/9] PCI: rpaphp: Annotate " Tyrel Datwyler
2019-11-11  5:21 ` [PATCH v2 8/9] PCI: rpaphp: Correctly match ibm,my-drc-index to drc-name when using drc-info Tyrel Datwyler
2019-11-11  5:21 ` [PATCH v2 9/9] powerpc/pseries: Enable support for ibm,drc-info property Tyrel Datwyler
2019-11-11 19:49 ` [PATCH v2 0/9] Fixes and Enablement of " Bjorn Helgaas
2019-11-12 10:50   ` Michael Ellerman

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=1573449697-5448-2-git-send-email-tyreld@linux.ibm.com \
    --to=tyreld@linux.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=bhelgaas@google.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=nathanl@linux.ibm.com \
    --cc=tlfalcon@linux.ibm.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).