Skip to content

Commit

Permalink
mgmt: ec_host_cmd: fix checking command version
Browse files Browse the repository at this point in the history
The sizeof is used in a wrong way which causes incorrect checking a
version of a command. Use NUM_BITS instead.

Signed-off-by: Dawid Niedzwiecki <[email protected]>
  • Loading branch information
niedzwiecki-dawid authored and carlescufi committed Jul 7, 2023
1 parent 521f0ba commit 40924ed
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion subsys/mgmt/ec_host_cmd/ec_host_cmd_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ static enum ec_host_cmd_status validate_handler(const struct ec_host_cmd_handler
return EC_HOST_CMD_INVALID_RESPONSE;
}

if (args->version > sizeof(handler->version_mask) ||
if (args->version >= NUM_BITS(handler->version_mask) ||
!(handler->version_mask & BIT(args->version))) {
return EC_HOST_CMD_INVALID_VERSION;
}
Expand Down

0 comments on commit 40924ed

Please sign in to comment.