Skip to contentSkip to conversation

FAILED: patch "[PATCH] pstore/ram: Avoid allocation and leak of platform data" failed to apply to 4.9-stable tree

PATCH [email protected] 1 participant 1 message Jan 21, 2019

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 4.9-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 5631e8576a3caf606cdc375f97425a67983b420c Mon Sep 17 00:00:00 2001
From: Kees Cook <[email protected]>
Date: Sun, 20 Jan 2019 14:33:34 -0800
Subject: [PATCH] pstore/ram: Avoid allocation and leak of platform data

Yue Hu noticed that when parsing device tree the allocated platform data was never freed. Since it's not used beyond the function scope, this switches to using a stack variable instead.

Fixes 35da60941e44 ("pstore/ram: add Device Tree bindings")
fs/pstore/ram.c +3 -6
index 076e26fdc0c0..898c8321b343 100644
@@ -710,18 +710,15 @@ static int ramoops_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct ramoops_platform_data *pdata = dev->platform_data;
+	struct ramoops_platform_data pdata_local;
 	struct ramoops_context *cxt = &oops_cxt;
 	size_t dump_mem_sz;
 	phys_addr_t paddr;
 	int err = -EINVAL;
 
 	if (dev_of_node(dev) && !pdata) {
-		pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
-		if (!pdata) {
-			pr_err("cannot allocate platform data buffer\n");
-			err = -ENOMEM;
-			goto fail_out;
-		}
+		pdata = &pdata_local;
+		memset(pdata, 0, sizeof(*pdata));
 
 		err = ramoops_parse_dt(pdev, pdata);
 		if (err < 0)