summaryrefslogtreecommitdiff
path: root/drivers/cpu/riscv_cpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpu/riscv_cpu.c')
-rw-r--r--drivers/cpu/riscv_cpu.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/cpu/riscv_cpu.c b/drivers/cpu/riscv_cpu.c
index 4f2958a23ce..d39a943cb84 100644
--- a/drivers/cpu/riscv_cpu.c
+++ b/drivers/cpu/riscv_cpu.c
@@ -5,6 +5,7 @@
*/
#include <clk.h>
+#include <common.h>
#include <cpu.h>
#include <dm.h>
#include <errno.h>
@@ -23,7 +24,7 @@ static int riscv_cpu_get_desc(const struct udevice *dev, char *buf, int size)
const char *cpu;
cpu = dev_read_string(dev, "compatible");
- if (size < (strlen(cpu) + 1))
+ if (!cpu || size < (strlen(cpu) + 1))
return -ENOSPC;
strcpy(buf, cpu);