diff options
author | Kees Cook <keescook@chromium.org> | 2019-01-20 14:33:34 -0800 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2019-01-20 14:44:52 -0800 |
commit | 5631e8576a3caf606cdc375f97425a67983b420c (patch) | |
tree | 4c5723127cca25af506b0edc6c8d75482d3e846f /fs/pstore | |
parent | 6a4c9ab13feeacd3072175d7d1f1fcfabbb9fc90 (diff) | |
download | lwn-5631e8576a3caf606cdc375f97425a67983b420c.tar.gz lwn-5631e8576a3caf606cdc375f97425a67983b420c.zip |
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: 35da60941e44 ("pstore/ram: add Device Tree bindings")
Cc: stable@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'fs/pstore')
-rw-r--r-- | fs/pstore/ram.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 076e26fdc0c0..898c8321b343 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -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) |