diff mbox series

[1/3] usb: typec: anx7411: Fix an array out of bounds

Message ID YtpC5s4/AD8vFz+X@kili (mailing list archive)
State Accepted
Commit cfed201e2db273562de152d22b74f74dee77e301
Headers show
Series [1/3] usb: typec: anx7411: Fix an array out of bounds | expand

Commit Message

Dan Carpenter July 22, 2022, 6:25 a.m. UTC
This should be ARRAY_SIZE() instead of sizeof().  ARRAY_SIZE is
4 and  sizeof is 8.

Fixes: fe6d8a9c8e64 ("usb: typec: anx7411: Add Analogix PD ANX7411 support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/usb/typec/anx7411.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Xin Ji July 22, 2022, 7:15 a.m. UTC | #1
On Fri, Jul 22, 2022 at 09:25:42AM +0300, Dan Carpenter wrote:
> This should be ARRAY_SIZE() instead of sizeof().  ARRAY_SIZE is
> 4 and  sizeof is 8.
Hi Dan Carpenter, thanks for your patch.

Reviewed-by: Xin Ji <xji@analogixsemi.com>

Thanks,
Xi
> 
> Fixes: fe6d8a9c8e64 ("usb: typec: anx7411: Add Analogix PD ANX7411 support")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/usb/typec/anx7411.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/anx7411.c b/drivers/usb/typec/anx7411.c
> index b990376991f8..4f7a5cc968d0 100644
> --- a/drivers/usb/typec/anx7411.c
> +++ b/drivers/usb/typec/anx7411.c
> @@ -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,
> -- 
> 2.35.1
diff mbox series

Patch

diff --git a/drivers/usb/typec/anx7411.c b/drivers/usb/typec/anx7411.c
index b990376991f8..4f7a5cc968d0 100644
--- a/drivers/usb/typec/anx7411.c
+++ b/drivers/usb/typec/anx7411.c
@@ -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,