incorrect mask/shift issue with qcom tsens thermal driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux