Skip to content

Commit 5631e85

Browse files
committed
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. Reported-by: Yue Hu <huyue2@yulong.com> Fixes: 35da609 ("pstore/ram: add Device Tree bindings") Cc: stable@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org>
1 parent 6a4c9ab commit 5631e85

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

fs/pstore/ram.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -710,18 +710,15 @@ static int ramoops_probe(struct platform_device *pdev)
710710
{
711711
struct device *dev = &pdev->dev;
712712
struct ramoops_platform_data *pdata = dev->platform_data;
713+
struct ramoops_platform_data pdata_local;
713714
struct ramoops_context *cxt = &oops_cxt;
714715
size_t dump_mem_sz;
715716
phys_addr_t paddr;
716717
int err = -EINVAL;
717718

718719
if (dev_of_node(dev) && !pdata) {
719-
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
720-
if (!pdata) {
721-
pr_err("cannot allocate platform data buffer\n");
722-
err = -ENOMEM;
723-
goto fail_out;
724-
}
720+
pdata = &pdata_local;
721+
memset(pdata, 0, sizeof(*pdata));
725722

726723
err = ramoops_parse_dt(pdev, pdata);
727724
if (err < 0)

0 commit comments

Comments
 (0)