Hide Forgot
Description of problem: /src/papi_pfm_events.c:820 - If return value from the function load_preset_table is NULL, NULL variable notemap will be dereferenced in the function free_notes (line #835). /src/ctests/do_loops.c:304 - Declaring variable "i" without initializer. /src/ctests/do_loops.c:309 - Using uninitialized value "i" if argc<=1 . /src/ctests/test_utils.c:813 - Comparing "hw_info" to null implies that "hw_info" might be null. /src/ctests/test_utils.c:820 - Passing null variable "hw_info->model_string" to function "strcmp", which dereferences it. Version-Release number of selected component (if applicable): papi-4.3.1-2 Additional info: These defects were not present in the previous version of package.
The array is zero'ed out before use in papi_pfm_events.c. Seems that static analysis tool is not following the man page that is a no-op. According to "man 3 free": free() frees the memory space pointed to by ptr, which must have been returned by a previous call to malloc(), calloc() or realloc(). Other- wise, or if free(ptr) has already been called before, undefined behav- ior occurs. If ptr is NULL, no operation is performed. The remaining two things flagged by the static analysis tool are in the test routines and do not end up in the binary rpms. Patches have been sent to the upstream papi developers to fix /src/ctests/do_loops.c and /src/ctests/test_utils.c However, it seems of limited utility to fix this particular set of issues in the RHEL rpm.
(In reply to comment #2) > The array is zero'ed out before use in papi_pfm_events.c. Seems that static > analysis tool is not following the man page that is a no-op. According to "man > 3 free": The tool does not care about man pages. It checks the code. Unless I am mistaken, the code is wrong. If load_preset_table() returns non-zero, you pass the NULL pointer to free_notes(), which is _not_ no-op. Please explain how exactly is the situation above handled by the code.
You are correct. Have patches to address the problems found in the scans. The patch /src/ctests/do_loops.c and /src/ctests/test_utils.c has been accepted upstream. The upstream has signficantly changed for papi_pfm_events.c, so that patch won't be applicable to papi upstream.
Built papi-4.1.3-3 with patches to fix the problems identified by coverity in this bz.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2011-1755.html