[LU-10772] New static analysis issues in v2_10_58_0-102-g1a5fdde Created: 05/Mar/18  Updated: 30/Aug/23  Resolved: 06/Oct/18

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.11.0
Fix Version/s: Lustre 2.12.0

Type: Bug Priority: Major
Reporter: Dmitry Eremin (Inactive) Assignee: Sonia Sharma (Inactive)
Resolution: Fixed Votes: 0
Labels: kw

Issue Links:
Related
is related to LU-4629 Issues found by static analysis tools Resolved
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

Found 2 new static analysis issues in v2_10_58_0-102-g1a5fdde:

  1. Suspicious dereference of pointer before NULL check
    • lnet/utils/lnetconfig/cyaml.c: in free_node, Suspicious dereference of pointer 'node' before NULL check at line 686
  2. Pointer may be dereferenced after it was positively checked for NULL
    • lustre/utils/lfs.c: in build_layout_from_yaml_node, Pointer 'string' checked for NULL at line 2192 may be dereferenced at line 2196. Also there is one similar error on line 2207.

The list of commits since the previous build v2_10_58_0-73-gda79fe8:

1a5fdde LU-10653 kernel: kernel update [SLES12 SP2 4.4.114-92.64]
2431891 LU-10655 tests: eliminate 'ssh exited with exit code 1'
eb8e82d LU-10716 tests: skip sanity 56xb for old server
d24d2f9 LU-10712 tests: skip conf-sanity 108[a,b] for old server
c716c76 LU-10684 tests: skip recovery-small 110[h-j]
5b5538e LU-10672 lnet: pass in only time64_t to lnet_notify
6a07b73 LU-10604 osd: define couple fields as bitfield
473a4ad LU-7787 mdd: clean up orphan object handling
860e20e LU-9325 obd: replace lprocfs_str_to_s64
c98a51f LU-10260 hsm: enable max archive_id posix copytool
ed91ee6 LU-10244 osc: add a bit to indicate osc_page in cache tree
9d62856 LU-9669 tests: check required nrs availability on a facet
a37134d LU-9624 tests: fix pre-DNE test exceptions/llog usage
eac95a6 LU-8912 nodemap: fix contiguous range support
5446b9b LU-8672 tests: Fix error handling in replay-single test_89
9ef9906 LU-6863 tests: change obdfilter-survey.sh for CLIENTONLY mode
c593dd0 LU-10657 utils: fd leak in mirror_split()
f5c6228 LU-10682 lnd: pending transmits dropped silently
feedd8f LU-9019 selftest: remove remaining cfs_time wrappers
1e7fc14 LU-10318 dom: support DATA_VERSION IO type
a74b2b5 LU-9431 obd: resolve config log sysfs issues
dfd3542 LU-10676 dkms: Provide lustre-dkms for lustre-zfs-dkms
64a49a1 LU-9761 dkms: Add ldiskfs dkms support
1a3cce7 LU-9324 lfs: add setstripe --yaml=template parameter
2a9518b LU-8727 mgs: remove skip records from config file
05cfe91 LU-9437 lfsck: handle LMV EA for migrating directory
54fc9a6 LU-10615 osd: stop OI scrub before FLDB closed
c2caa40 Revert "LU-8856 osd: mark specific transactions netfree"
a042ad4 LU-8878 tests: skip several tests for CLIENTONLY mode


 Comments   
Comment by Dmitry Eremin (Inactive) [ 05/Mar/18 ]

The first issue is just a warning about redundant "if (node)" operator.

static bool free_node(struct cYAML *node, void *user_data, void **out)
{
	if (node->cy_type == CYAML_TYPE_STRING)
		free(node->cy_valuestring);
	if (node->cy_string)
		free(node->cy_string);
	if (node)
		free(node);
 
	return true;
}

Comment by Peter Jones [ 05/Mar/18 ]

Sonia

Could you please investigate

Thanks

Peter

Comment by Oleg Drokin [ 05/Mar/18 ]

I think it's better to move the check to the function start. Something like:

if (!node)
    return true;

rest of stuff
Comment by Gerrit Updater [ 06/Mar/18 ]

Sonia Sharma (sonia.sharma@intel.com) uploaded a new patch: https://review.whamcloud.com/31537
Subject: LU-10772 utils: static analysis issues
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 76908c5ced2a3979af8c398eb745c33ac67da065

Comment by Gerrit Updater [ 06/Mar/18 ]

Sonia Sharma (sonia.sharma@intel.com) uploaded a new patch: https://review.whamcloud.com/31551
Subject: LU-10772 utils: incorrect NULL check in free_node()
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 34f15a85cbd03f007ade66652bb0a5aa0bccf004

Comment by Gerrit Updater [ 15/Mar/18 ]

Oleg Drokin (oleg.drokin@intel.com) merged in patch https://review.whamcloud.com/31551/
Subject: LU-10772 utils: incorrect NULL check in free_node()
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 782736f7c5cf96ae72bf6ee8791764130e2447d8

Comment by Gerrit Updater [ 05/Oct/18 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/31537/
Subject: LU-10772 utils: incorrect check in build_layout_from_yaml_node
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 13bee727125202ff8519163fc72581f359532b90

Comment by Peter Jones [ 06/Oct/18 ]

Landed for 2.12

Generated at Sat Feb 10 02:38:03 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.