drm/amd/display: Fix static analysis bug in validate_bksv

[Why]
static analysis throws the error below

Out-of-bounds read (OVERRUN)
Overrunning array of 5 bytes at byte offset 7 by dereferencing pointer
(uint64_t *)hdcp->auth.msg.hdcp1.bksv.

var n is going to contain  r0p and bcaps. if they are non-zero the count
will be wrong

How]
Use memcpy instead to avoid this.

Signed-off-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Bhawanpreet Lakha 2019-11-06 14:58:45 -05:00 committed by Alex Deucher
parent 3021690037
commit a1acc5d094
1 changed files with 3 additions and 1 deletions

View File

@ -27,9 +27,11 @@
static inline enum mod_hdcp_status validate_bksv(struct mod_hdcp *hdcp)
{
uint64_t n = *(uint64_t *)hdcp->auth.msg.hdcp1.bksv;
uint64_t n = 0;
uint8_t count = 0;
memcpy(&n, hdcp->auth.msg.hdcp1.bksv, sizeof(uint64_t));
while (n) {
count++;
n &= (n - 1);