stm32mp1: Add check on syscon_get_first_range() return value

syscon_get_first_range()'s return value is used as base address to perform
a read, without any checks.
In case stmp32mp_syscon is not binded, syscon_get_first_range() returns
-ENODEV which leads to a "Synchronous abort".

Add syscon_get_first_range() check on return value.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
This commit is contained in:
Patrice Chotard
2026-02-04 11:16:08 +01:00
parent ab965d31a2
commit ac7f28523c

View File

@@ -17,6 +17,7 @@
#include <dm/device.h>
#include <dm/uclass.h>
#include <linux/bitfield.h>
#include <linux/err.h>
#include <malloc.h>
/* RCC register */
@@ -231,6 +232,12 @@ static u32 read_idc(void)
{
void *syscfg = syscon_get_first_range(STM32MP_SYSCON_SYSCFG);
if (IS_ERR(syscfg)) {
pr_err("Error, can't get SYSCON range (%ld)\n", PTR_ERR(syscfg));
return PTR_ERR(syscfg);
}
return readl(syscfg + SYSCFG_IDC_OFFSET);
}