Skip to content

Commit

Permalink
pstore/ram: Fix error return code in ramoops_probe()
Browse files Browse the repository at this point in the history
[ Upstream commit e1fce56 ]

In the if (dev_of_node(dev) && !pdata) path, the "err" may be assigned a
value of 0, so the error return code -EINVAL may be incorrectly set
to 0. To fix set valid return code before calling to goto.

Fixes: 35da609 ("pstore/ram: add Device Tree bindings")
Signed-off-by: Wang Yufen <wangyufen@huawei.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/1669969374-46582-1-git-send-email-wangyufen@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
wangyufen316 authored and gregkh committed Dec 31, 2022
1 parent 5b81f0c commit 65f1ff9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/pstore/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,13 +735,15 @@ static int ramoops_probe(struct platform_device *pdev)
/* Make sure we didn't get bogus platform data pointer. */
if (!pdata) {
pr_err("NULL platform data\n");
err = -EINVAL;
goto fail_out;
}

if (!pdata->mem_size || (!pdata->record_size && !pdata->console_size &&
!pdata->ftrace_size && !pdata->pmsg_size)) {
pr_err("The memory size and the record/console size must be "
"non-zero\n");
err = -EINVAL;
goto fail_out;
}

Expand Down

0 comments on commit 65f1ff9

Please sign in to comment.