Bug 170411 - [ath] Uninitialized variables in if_ath.c
Summary: [ath] Uninitialized variables in if_ath.c
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: wireless (show other bugs)
Version: 10.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-wireless (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-06 09:30 UTC by Dimitry Andric
Modified: 2014-06-07 05:29 UTC (History)
0 users

See Also:


Attachments
file.diff (427 bytes, patch)
2012-08-06 09:30 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer freebsd_triage 2012-08-06 09:30:05 UTC
I'm busy with importing a new clang snapshot into head. This version
has a bunch of interesting new warnings, and I got the following one
during building of ath:

  sys/dev/ath/if_ath.c:4337:6: error: variable 'isCalDone' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
	  if (shortCal || longCal) {
	      ^~~~~~~~~~~~~~~~~~~
  sys/dev/ath/if_ath.c:4354:7: note: uninitialized use occurs here
	  if (!isCalDone) {
	       ^~~~~~~~~
  sys/dev/ath/if_ath.c:4337:2: note: remove the 'if' if its condition is always true
	  if (shortCal || longCal) {
	  ^~~~~~~~~~~~~~~~~~~~~~~~~
  sys/dev/ath/if_ath.c:4288:2: note: variable 'isCalDone' is declared here
	  HAL_BOOL longCal, isCalDone;
	  ^

It's because isCalDone is never initialized, if shortCal and longCal are
both false.  In that case, the next test for isCalDone will have an
unpredictable result.

Looking at the code in the various ar5xxxPerCalibrationN() functions,
they only seem to set isCalDone to AH_TRUE in the explicit case
calibration succeeded, so initializing isCalDone to AH_FALSE at the
start of ath_calibrate() looks like the safest thing to do.

Please see the attached patch.

Fix: Patch attached with submission follows:
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2013-08-19 04:12:26 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-wireless

Over to maintainer(s).
Comment 2 Dimitry Andric freebsd_committer freebsd_triage 2014-06-03 20:23:16 UTC
Fixed in r241229.