[PATCH] riscv: cpuinfo: Fix NULL dereference and inconsistent error code

Michael Ellerman mpe at kernel.org
Sun May 3 05:26:06 PDT 2026


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




More information about the linux-riscv mailing list