Browse Source

fix(st-clock): correct stm32_clk_parse_fdt_by_name

The fdt_getprop() function sets the length to -1 if the property is not
found. We should then not use it later in stm32_clk_parse_fdt_by_name()
in that case. Directly set *nb to 0U and return 0 if the property is not
found.

Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
Change-Id: I19c5c953f392cdc768e0b1f3f240fc99a73a049c
pull/1985/head
Yann Gautier 3 years ago
committed by Yann Gautier
parent
commit
7417cda6ae
  1. 13
      drivers/st/clk/clk-stm32-core.c

13
drivers/st/clk/clk-stm32-core.c

@ -1073,12 +1073,15 @@ int stm32_clk_parse_fdt_by_name(void *fdt, int node, const char *name, uint32_t
uint32_t i;
cell = fdt_getprop(fdt, node, name, &len);
if (cell != NULL) {
for (i = 0; i < ((uint32_t)len / sizeof(uint32_t)); i++) {
uint32_t val = fdt32_to_cpu(cell[i]);
if (cell == NULL) {
*nb = 0U;
return 0;
}
tab[i] = val;
}
for (i = 0; i < ((uint32_t)len / sizeof(uint32_t)); i++) {
uint32_t val = fdt32_to_cpu(cell[i]);
tab[i] = val;
}
*nb = (uint32_t)len / sizeof(uint32_t);

Loading…
Cancel
Save