]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
board: phytec: imx8m_som_detection: fix uninitialized pointer bug
authorYannic Moog <y.moog@phytec.de>
Wed, 20 Dec 2023 08:45:33 +0000 (09:45 +0100)
committerFabio Estevam <festevam@denx.de>
Wed, 20 Dec 2023 18:04:46 +0000 (15:04 -0300)
Pointer in phytec_imx8m_detect was accessed without checking it first.
Fix this by moving the pointer check in front of any accesses.

Signed-off-by: Yannic Moog <y.moog@phytec.de>
board/phytec/common/imx8m_som_detection.c

index 45f5767c565e64df24dd89aef79cba71f7d65625..a229eae152d50ee39a003564c5478b3cca6ce40b 100644 (file)
@@ -28,13 +28,13 @@ int __maybe_unused phytec_imx8m_detect(struct phytec_eeprom_data *data)
        char *opt;
        u8 som;
 
+       if (!data)
+               data = &eeprom_data;
+
        /* We can not do the check for early API revisions */
        if (data->api_rev < PHYTEC_API_REV2)
                return -1;
 
-       if (!data)
-               data = &eeprom_data;
-
        som = data->data.data_api2.som_no;
        debug("%s: som id: %u\n", __func__, som);