Skip to content

Commit

Permalink
board: phytec: phytec_som_detection: fix uninitialized bug
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ymoog authored and Fabio Estevam committed Dec 20, 2023
1 parent aa7858f commit e2449ee
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion board/phytec/common/phytec_som_detection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ",
Expand Down

0 comments on commit e2449ee

Please sign in to comment.