Skip to content

Commit

Permalink
usb: typec: anx7411: Fix an array out of bounds
Browse files Browse the repository at this point in the history
This should be ARRAY_SIZE() instead of sizeof().  ARRAY_SIZE is
4 and  sizeof is 8.

Fixes: fe6d8a9 ("usb: typec: anx7411: Add Analogix PD ANX7411 support")
Reviewed-by: Xin Ji <xji@analogixsemi.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YtpC5s4/AD8vFz+X@kili
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Dan Carpenter authored and Greg Kroah-Hartman committed Jul 27, 2022
1 parent ff50a91 commit cfed201
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/usb/typec/anx7411.c
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ static int anx7411_register_i2c_dummy_clients(struct anx7411_data *ctx,
int i;
u8 spi_addr;

for (i = 0; i < sizeof(anx7411_i2c_addr); i++) {
for (i = 0; i < ARRAY_SIZE(anx7411_i2c_addr); i++) {
if (client->addr == (anx7411_i2c_addr[i].tcpc_address >> 1)) {
spi_addr = anx7411_i2c_addr[i].spi_address >> 1;
ctx->spi_client = i2c_new_dummy_device(client->adapter,
Expand Down

0 comments on commit cfed201

Please sign in to comment.