RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 736006 - Defects revealed by the Coverity scan
Summary: Defects revealed by the Coverity scan
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: papi
Version: 6.2
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: William Cohen
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks: 743047
TreeView+ depends on / blocked
 
Reported: 2011-09-06 11:54 UTC by Michal Luscon
Modified: 2011-12-06 18:56 UTC (History)
4 users (show)

Fixed In Version: papi-4.1.0-3.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-12-06 18:56:09 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1755 0 normal SHIPPED_LIVE papi bug fix and enhancement update 2011-12-06 01:01:43 UTC

Description Michal Luscon 2011-09-06 11:54:58 UTC
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.

Comment 2 William Cohen 2011-09-06 20:48:21 UTC
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.

Comment 3 Kamil Dudka 2011-09-06 21:40:59 UTC
(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.

Comment 4 William Cohen 2011-09-08 17:02:55 UTC
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.

Comment 6 William Cohen 2011-09-09 19:57:08 UTC
Built papi-4.1.3-3 with patches to fix the problems identified by coverity in this bz.

Comment 11 errata-xmlrpc 2011-12-06 18:56:09 UTC
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


Note You need to log in before you can comment on or make changes to this bug.