papr_scm_probe() reads "ibm,metadata-size" into metadata_size without
checking the return value, and the property is optional, as the comment
right above the call says. of_property_read_u32() only writes the output
when it can decode a value, so for a device tree without that property
p->metadata_size is set from an uninitialised stack value.
p->metadata_size is the bound for the metadata get/set commands:
if ((hdr->in_offset + hdr->in_length) > p->metadata_size)
so a garbage value decides which metadata accesses are accepted.
Initialise it to zero, which makes those commands reject every access
when the platform does not advertise a metadata area.
Signed-off-by: Hyunjung Ko <[email protected]>
Cc: [email protected]
---
arch/powerpc/platforms/pseries/papr_scm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/pseries/papr_scm.c
b/arch/powerpc/platforms/pseries/papr_scm.c
index 5c3bf06bb59b..e9895e9b070c 100644
--- a/arch/powerpc/platforms/pseries/papr_scm.c
+++ b/arch/powerpc/platforms/pseries/papr_scm.c
@@ -1361,7 +1361,7 @@ static struct notifier_block mce_ue_nb =
static int papr_scm_probe(struct platform_device *pdev)
{
struct device_node *dn = pdev->dev.of_node;
- u32 drc_index, metadata_size;
+ u32 drc_index, metadata_size = 0;
u64 blocks, block_size;
struct papr_scm_priv *p;
u8 uuid_raw[UUID_SIZE];
--
2.51.0