diff options
| author | Evan Lojewski <github@meklort.com> | 2020-04-11 20:34:40 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-11 20:34:40 -0600 |
| commit | a985bfd6cdbe977e02c72de85f958e74ddf372e7 (patch) | |
| tree | 49fca1761d01f1ed258738b8772df7684e4338e6 /simulator/HAL.cpp | |
| parent | dc9705b4c65aa6b059a2f6beaf4d370620e583b7 (diff) | |
| download | bcm5719-ortega-a985bfd6cdbe977e02c72de85f958e74ddf372e7.tar.gz bcm5719-ortega-a985bfd6cdbe977e02c72de85f958e74ddf372e7.zip | |
coverity: Fix issues found with coverity (#78)
Diffstat (limited to 'simulator/HAL.cpp')
| -rw-r--r-- | simulator/HAL.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/simulator/HAL.cpp b/simulator/HAL.cpp index e6febb7..aea268b 100644 --- a/simulator/HAL.cpp +++ b/simulator/HAL.cpp @@ -184,7 +184,7 @@ static char* locate_pci_path(int wanted_function) { pci_config_t config; - if (fread(&config, sizeof(config), 1, pConfigFile)) + if (1 == fread(&config, sizeof(config), 1, pConfigFile)) { if (is_supported(config.vendor_id, config.device_id)) { @@ -240,8 +240,11 @@ bool initHAL(const char *pci_path, int wanted_function) } pci_config_t config; + size_t read_count = fread(&config, sizeof(config), 1, pConfigFile); - if (fread(&config, sizeof(config), 1, pConfigFile)) + fclose(pConfigFile); + + if (1 == read_count) { if (is_supported(config.vendor_id, config.device_id)) { @@ -255,7 +258,7 @@ bool initHAL(const char *pci_path, int wanted_function) if ((memfd = open(pBARPath, O_RDWR | O_SYNC)) < 0) { printf("Error opening %s file. \n", pBARPath); - close(memfd); + if(located_pci_path) { free(located_pci_path); @@ -274,6 +277,9 @@ bool initHAL(const char *pci_path, int wanted_function) { free(located_pci_path); } + + close(memfd); + return false; } @@ -287,6 +293,9 @@ bool initHAL(const char *pci_path, int wanted_function) { free(located_pci_path); } + + close(memfd); + return false; } @@ -297,6 +306,16 @@ bool initHAL(const char *pci_path, int wanted_function) } } } + else + { + // Unable to read configuration. Exit. + if(located_pci_path) + { + free(located_pci_path); + } + + return false; + } if(located_pci_path) { |

