Bug 1394235

Summary: gfs2-utils: Fixes for static analysis warnings
Product: Red Hat Enterprise Linux 6 Reporter: Andrew Price <anprice>
Component: clusterAssignee: Andrew Price <anprice>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.9CC: ccaulfie, cluster-maint, gfs2-maint, rpeterso, teigland
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: cluster-3.0.12.1-84.el6 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-03-21 09:26:48 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
RHEL6 version of the upstream patch none

Description Andrew Price 2016-11-11 12:58:20 UTC
This bz is for valid issues reported by covscan for gfs2-utils and not covered by other bug reports. Just the one to begin with:

http://cov01.lab.eng.brq.redhat.com/covscanhub/waiving/15317/54510/#defect_1057213

1. Defect type: CLANG_WARNING
1. cluster-3.0.12.1/gfs2/fsck/main.c:187:18: warning: The left operand of '==' is a garbage value
#         if (sc.sc_total == sdp->blks_total &&
#             ~~~~~~~~~~~ ^
4. cluster-3.0.12.1/gfs2/fsck/main.c:162:16: note: Left side of '&&' is false
#         if (sdp->gfs1 && !sdp->md.statfs->i_di.di_size) {
#                       ^
7. cluster-3.0.12.1/gfs2/fsck/main.c:169:2: note: Taking false branch
#         if (count == sizeof(struct gfs2_statfs_change))
#         ^
10. cluster-3.0.12.1/gfs2/fsck/main.c:177:2: note: Loop condition is false. Execution continues on line 187
#         for (n = osi_first(&sdp->rgtree); n; n = next) {
#         ^
13. cluster-3.0.12.1/gfs2/fsck/main.c:187:18: note: The left operand of '==' is a garbage value
#         if (sc.sc_total == sdp->blks_total &&
#             ~~~~~~~~~~~ ^
#   185|   
#   186|   	/* See if they match */
#   187|-> 	if (sc.sc_total == sdp->blks_total &&
#   188|   	    sc.sc_free == (sdp->blks_total - sdp->blks_alloced) &&
#   189|   	    sc.sc_dinodes == sdp->dinodes_alloced) {

Upstream fixes this just by initialising sc but a better fix would be to handle the earlier error condition from gfs2_readi() such that the function returns instead of leaving sc to be a garbage value.

Comment 2 Andrew Price 2016-11-15 12:59:08 UTC
Created attachment 1220829 [details]
RHEL6 version of the upstream patch

The RHEL6 version of the patch is slightly larger than upstream as check_statfs() was a void function. I've run it through covscan using the same base as ET and it shows that the issue has been fixed: http://cov01.lab.eng.brq.redhat.com/covscanhub/task/32817/log/fixed.html

Comment 6 Nate Straz 2017-01-23 16:37:49 UTC
Verified source of cluster-3.0.12.1-84.el6 include the attached patch.

Comment 8 errata-xmlrpc 2017-03-21 09:26:48 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.

https://rhn.redhat.com/errata/RHBA-2017-0601.html