summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
74e0d3a)
Unsuccesfull memory allocation for elements inside cfgfile
structure could result in resource leak.
Fixed by pointer verification after each malloc,
if malloc fail - error branch is proceeded with freeing memory.
Coverity issue: 195032
Fixes:
d4cb8197589d ("cfgfile: support runtime modification")
Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
Acked-by: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>
CFG_ALLOC_SECTION_BATCH);
if (cfg->sections == NULL)
CFG_ALLOC_SECTION_BATCH);
if (cfg->sections == NULL)
cfg->allocated_sections = CFG_ALLOC_SECTION_BATCH;
cfg->allocated_sections = CFG_ALLOC_SECTION_BATCH;
struct rte_cfgfile_entry) * CFG_ALLOC_ENTRY_BATCH);
if (cfg->sections[i].entries == NULL)
struct rte_cfgfile_entry) * CFG_ALLOC_ENTRY_BATCH);
if (cfg->sections[i].entries == NULL)
cfg->sections[i].num_entries = 0;
cfg->sections[i].allocated_entries = CFG_ALLOC_ENTRY_BATCH;
cfg->sections[i].num_entries = 0;
cfg->sections[i].allocated_entries = CFG_ALLOC_ENTRY_BATCH;
if (flags & CFG_FLAG_GLOBAL_SECTION)
rte_cfgfile_add_section(cfg, "GLOBAL");
if (flags & CFG_FLAG_GLOBAL_SECTION)
rte_cfgfile_add_section(cfg, "GLOBAL");
+error1:
+ if (cfg->sections != NULL) {
+ for (i = 0; i < cfg->allocated_sections; i++) {
+ if (cfg->sections[i].entries != NULL) {
+ free(cfg->sections[i].entries);
+ cfg->sections[i].entries = NULL;
+ }
+ }
+ free(cfg->sections);
+ cfg->sections = NULL;
+ }
+ free(cfg);
+ return NULL;