Skip to content

Commit

Permalink
media: venus: core,pm: fix potential infinite loop
Browse files Browse the repository at this point in the history
The for-loop iterates with a u8 loop counter i and compares this
with the loop upper limit of res->resets_num which is an unsigned
int type.  There is a potential infinite loop if res->resets_num
is larger than the u8 loop counter i. Fix this by making the loop
counter the same type as res->resets_num.

Addresses-Coverity: ("Infinite loop")

Fixes: 3bca435 ("media: venus: core,pm: Add handling for resets")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
  • Loading branch information
Colin Ian King authored and Mauro Carvalho Chehab committed Apr 15, 2021
1 parent c9072b6 commit 999267d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/media/platform/qcom/venus/pm_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ static void vcodec_domains_put(struct venus_core *core)
static int core_resets_reset(struct venus_core *core)
{
const struct venus_resources *res = core->res;
unsigned char i;
unsigned int i;
int ret;

if (!res->resets_num)
Expand All @@ -893,7 +893,7 @@ static int core_resets_get(struct venus_core *core)
{
struct device *dev = core->dev;
const struct venus_resources *res = core->res;
unsigned char i;
unsigned int i;
int ret;

if (!res->resets_num)
Expand Down

0 comments on commit 999267d

Please sign in to comment.