diff mbox series

[4/4] board: phytec: phytec_som_detection: fix uninitialized bug

Message ID 20231220-wip-y-moog-phytec-de-upstream_som_detection_fixes-v1-4-c24f3239b4c3@phytec.de
State Superseded
Delegated to: Fabio Estevam
Headers show
Series This series fixes various bugs in the phytec som_detection unit. | expand

Commit Message

Yannic Moog Dec. 20, 2023, 8:19 a.m. UTC
When som_type does not match any case, it is uninitialized and the
function still tries to print the SoM info. Rather, this is an error
condition and the function should abort prematurely. Highlight this by
printing an error message and returning early.

Signed-off-by: Yannic Moog <y.moog@phytec.de>
---
 board/phytec/common/phytec_som_detection.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/board/phytec/common/phytec_som_detection.c b/board/phytec/common/phytec_som_detection.c
index f879702df45..1b10923b62f 100644
--- a/board/phytec/common/phytec_som_detection.c
+++ b/board/phytec/common/phytec_som_detection.c
@@ -161,7 +161,8 @@  void __maybe_unused phytec_print_som_info(struct phytec_eeprom_data *data)
 			sub_som_type2 = 2;
 			break;
 		default:
-			break;
+			pr_err("%s: Invalid SoM type: %i", __func__, api2->som_type);
+			return;
 		};
 
 		printf("SoM: %s-%03u-%s-%03u ",