#4462 closed defect (fixed)

CID 1437638: Logically dead code

Reported by: Harrison Gerber Owned by: Gedare Bloom
Priority: normal Milestone: 6.1
Component: admin Version: 6
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

In rtems-fdt.c:

The indicated dead code may have performed some action; that action will never occur.

In rtems_fdt_init_index: Code can never be reached because of a logical contradiction (CWE-561)

159  entries = calloc(num_entries, sizeof(rtems_fdt_index_entry));
   	cond_notnull: Condition entries, taking true branch. Now the value of entries is not NULL.
160  if (!entries)
161  {
162    return -RTEMS_FDT_ERR_NO_MEMORY;
163  }
164
165  names = calloc(1, total_name_memory);
   	notnull: At condition entries, the value of entries cannot be NULL.
   	dead_error_condition: The condition !entries cannot be true.
166  if (!entries)
167  {
   	
CID 1437638 (#1 of 1): Logically dead code (DEADCODE)
dead_error_begin: Execution cannot reach this statement: free(entries);.
168    free(entries);
169    return -RTEMS_FDT_ERR_NO_MEMORY;
170  }

Change History (4)

comment:1 Changed on 06/29/21 at 00:31:27 by Joel Sherrill

Shouldn't it be freeing the first variable allocated -- names?

comment:2 Changed on 10/03/22 at 18:13:45 by Kinsey Moore <kinsey.moore@…>

In cab00c70/rtems:

cpukit/fdt: Check correct allocation

The second allocation check was mistakenly rechecking the first
allocation. It now checks the correct allocation and ensures that names
is not NULL.

Updates #4462

comment:3 Changed on 10/03/22 at 18:14:04 by Kinsey Moore <kinsey.moore@…>

In 584f5bc9/rtems:

cpukit/fdt: Check correct allocation

The second allocation check was mistakenly rechecking the first
allocation. It now checks the correct allocation and ensures that names
is not NULL.

Updates #4462

comment:4 Changed on 10/31/22 at 15:02:09 by Gedare Bloom

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.