Skip to contentSkip to conversation

pstore/ram: Fix error return code in ramoops_probe()

PATCH Applied Wang Yufen 2 participants 2 messages Dec 2, 2022 Pstore filesystem

lore
Share & tools
lore

Wang Yufen

author
#0 lore raw

PATCH 1/1 pstore/ram: Fix error return code in ramoops_probe()

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 35da60941e44 ("pstore/ram: add Device Tree bindings")
---
 fs/pstore/ram.c | 2 ++
 1 file changed, 2 insertions(+)
fs/pstore/ram.c +2 -0
index fefe3d3..74e4d93 100644
@@ -735,6 +735,7 @@ 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;
 	}
 
@@ -742,6 +743,7 @@ static int ramoops_probe(struct platform_device *pdev)
 			!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;
 	}
 
Signature · 1 line
1.8.3.1
Applied
#1 lore raw
Quoted 5 lines · Wang Yufen

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.

Applied to for-next/pstore, thanks!

[1/1] pstore/ram: Fix error return code in ramoops_probe()

      https://git.kernel.org/kees/c/e1fce564900f
Signature · 1 line
Kees Cook