Re: [PATCH] riscv: cpuinfo: Fix NULL dereference and inconsistent error code
From: Michael Ellerman
Date: Sun May 03 2026 - 08:31:12 EST
On 3/5/2026 02:17, Mohamed Ayman wrote:
Fix a potential NULL pointer dereference in c_show() by ensuring
the device tree node returned by of_get_cpu_node() is checked before use.
Where is the NULL pointer deref?
of_property_read_string() can cope with a NULL np, it just returns an error.
of_node_put() also handles a NULL np.
Also replace a non-standard return value (-1) in
riscv_of_parent_hartid() with -ENODEV to follow Linux kernel
conventions for "not found" error returns.
That should be a separate patch. It does look like a good change. At least some of the callers of riscv_of_parent_hartid() pass the return value up to their callers, so -1 could be misinterpreted somewhere as EPERM.
cheers