From: Colin Ian King <colin.king@canonical.com>
To: Amit Kucheria <amit.kucheria@linaro.org>,
Andy Gross <andy.gross@linaro.org>,
David Brown <david.brown@linaro.org>
Cc: Zhang Rui <rui.zhang@intel.com>,
Eduardo Valentin <edubezval@gmail.com>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: incorrect mask/shift issue with qcom tsens thermal driver
Date: Tue, 20 Apr 2021 17:49:57 +0100 [thread overview]
Message-ID: <aac16b20-12e7-5925-2c25-ee11b237a431@canonical.com> (raw)
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
reply other threads:[~2021-04-20 16:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aac16b20-12e7-5925-2c25-ee11b237a431@canonical.com \
--to=colin.king@canonical.com \
--cc=amit.kucheria@linaro.org \
--cc=andy.gross@linaro.org \
--cc=daniel.lezcano@linaro.org \
--cc=david.brown@linaro.org \
--cc=edubezval@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).