* 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, other threads:[~2021-04-20 16:50 UTC | newest]
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).