Skip to content

Commit

Permalink
drm/amd/display: Fix false BAD_FREE warning from Coverity
Browse files Browse the repository at this point in the history
This is an attempt to fix false warning raised by Coverity
via multiple CID's.

Addresses-Coverity-ID: 1487412 ("Free of address-of expression")
Cc: Wesley Chalmers <Wesley.Chalmers@amd.com>

Reviewed-by: Wesley Chalmers <wesley.chalmers@amd.com>
Acked-by: Mikita Lipski <mikita.lipski@amd.com>
Signed-off-by: Anson Jacob <Anson.Jacob@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
  • Loading branch information
Anson Jacob authored and Alex Deucher committed Sep 14, 2021
1 parent 64d283c commit 5e1a9a3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/gpu/drm/amd/display/dc/core/dc_link_dpcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,15 @@ static void dpcd_reduce_address_range(
uint8_t * const reduced_data,
const uint32_t reduced_size)
{
const uint32_t reduced_end_address = END_ADDRESS(reduced_address, reduced_size);
const uint32_t extended_end_address = END_ADDRESS(extended_address, extended_size);
const uint32_t offset = reduced_address - extended_address;

if (extended_end_address == reduced_end_address && extended_address == reduced_address)
return; /* extended and reduced address ranges point to the same data */
/*
* If the address is same, address was not extended.
* So we do not need to free any memory.
* The data is in original buffer(reduced_data).
*/
if (extended_data == reduced_data)
return;

memcpy(&extended_data[offset], reduced_data, reduced_size);
kfree(extended_data);
Expand Down

0 comments on commit 5e1a9a3

Please sign in to comment.