Linux-ARM-MSM Archive on lore.kernel.org
 help / color / Atom feed
* incorrect mask/shift issue with qcom tsens thermal driver
@ 2021-04-20 16:49 Colin Ian King
  0 siblings, 0 replies; only message in thread
From: Colin Ian King @ 2021-04-20 16:49 UTC (permalink / raw)
  To: Amit Kucheria, Andy Gross, David Brown
  Cc: Zhang Rui, Eduardo Valentin, Daniel Lezcano, linux-pm, linux-arm-msm

Hi,

Static analysis on drivers/thermal/qcom/tsens-v0_1.c has found an issue
in function calibrate_8974 with an incorrect mask value used when
shifting a value. The analysis by Coverity is as follows:


400                        p1[5] = (bkp[1] & S5_P1_MASK) >> S5_P1_SHIFT;
401                        p1[6] = (bkp[1] & S6_P1_MASK) >> S6_P1_SHIFT;
402                        p1[7] = (bkp[1] & S7_P1_MASK) >> S7_P1_SHIFT;

Operands don't affect result (CONSTANT_EXPRESSION_RESULT)
result_independent_of_operands: (bkp[2] & 63) >> 24 is 0 regardless of
the values of its operands. This occurs as the operand of assignment.

403                        p1[8] = (bkp[2] & S8_P1_MASK_BKP) >> S8_P1_SHIFT;


S8_P1_MASK_BKP is 0x3f
S8_P1_SHIFT is 24

so anything masked with 03f and right shifted 24 places will be zero, so
this looks incorrect.  I suspect the mask should be 0x3f000000.

My thinking is that this is a typo, and should be:

	 p1[8] = (bkp[2] & S8_P1_MASK) >> S8_P1_SHIFT;

since S8_P1_MASK is 0x3f000000. However, I'm not 100% sure as I don't
have the EEPROM layout so it maybe that S8_P1_MASK_BKP is incorrectly
#defined.

Any thoughts?

Colin

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20 16:49 incorrect mask/shift issue with qcom tsens thermal driver Colin Ian King

Linux-ARM-MSM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-msm/0 linux-arm-msm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-msm linux-arm-msm/ https://lore.kernel.org/linux-arm-msm \
		linux-arm-msm@vger.kernel.org
	public-inbox-index linux-arm-msm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-arm-msm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git