Skip to content

Commit 0c198f9

Browse files
mbolivar-nordiccarlescufi
authored andcommitted
drivers: entropy: fail mcux CAAM init on error
Commit d556a0c ("drivers: entropy: Add entropy driver for MCUX CAAM") added a shim entropy driver whose initialization function always returns 0, even when the underlying HAL API fails. This is wrong; if the device initialization function fails, it must return nonzero by contract. Papering this over with an assert is not enough. Fix it by returning -ENODEV on error. Signed-off-by: Martí Bolívar <[email protected]>
1 parent 598de06 commit 0c198f9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/entropy/entropy_mcux_caam.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ static int entropy_mcux_caam_init(const struct device *dev)
5757
status = CAAM_Init(config->base, &conf);
5858
__ASSERT_NO_MSG(!status);
5959

60+
if (status != 0) {
61+
return -ENODEV;
62+
}
63+
6064
return 0;
6165
}
6266

0 commit comments

Comments
 (0)