Skip to contentSkip to conversation

pinctrl: tegra-xusb: fix an off by one test

PATCH In review Dan Carpenter 4 participants 5 messages Jul 31, 2014 – Aug 11, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 pinctrl: tegra-xusb: fix an off by one test

This shoudld be ">= ARRAY_SIZE()" instead of "> ARRAY_SIZE()".

Fixes dc0a39386687 ('pinctrl: Add NVIDIA Tegra XUSB pad controller support')
drivers/pinctrl/pinctrl-tegra-xusb.c +1 -1
index a066204..419a047 100644
@@ -680,7 +680,7 @@ static struct phy *tegra_xusb_padctl_xlate(struct device *dev,
 	if (args->args_count <= 0)
 		return ERR_PTR(-EINVAL);
 
-	if (index > ARRAY_SIZE(padctl->phys))
+	if (index >= ARRAY_SIZE(padctl->phys))
 		return ERR_PTR(-EINVAL);
 
 	return padctl->phys[index];
#1 lore raw
Quoted 4 lines · Dan Carpenter

This shoudld be ">= ARRAY_SIZE()" instead of "> ARRAY_SIZE()".

Fixes dc0a39386687 ('pinctrl: Add NVIDIA Tegra XUSB pad controller support')

This series looks fine to me.

Linus, since the XUSB driver got merged through the Tegra tree, should I send these fixes through arm-soc on top of the driver addition patches (hoping to get them in before -rc1), or will you take them through the pinctrl tree immediately after -rc1? The latter might be simpler.

#2 lore raw
Quoted 10 lines · Stephen Warren
Quoted 6 lines · Dan Carpenter

This shoudld be ">= ARRAY_SIZE()" instead of "> ARRAY_SIZE()".

Fixes dc0a39386687 ('pinctrl: Add NVIDIA Tegra XUSB pad controller

support')

This series looks fine to me.

I record this as an Acked-by.

Quoted 4 lines

Linus, since the XUSB driver got merged through the Tegra tree, should I send these fixes through arm-soc on top of the driver addition patches (hoping to get them in before -rc1), or will you take them through the pinctrl tree immediately after -rc1? The latter might be simpler.

Yeah I'm carrying them.

Thanks!
Linus Walleij

Acked-by on v1 1/2
#3 lore raw
In reply to Dan Carpenter
Quoted 10 lines · Dan Carpenter

This shoudld be ">= ARRAY_SIZE()" instead of "> ARRAY_SIZE()".

Fixes dc0a39386687 ('pinctrl: Add NVIDIA Tegra XUSB pad controller support')
drivers/pinctrl/pinctrl-tegra-xusb.c +0 -0
index a066204..419a047 100644

drivers/pinctrl/pinctrl-tegra-xusb.c static struct phy *tegra_xusb_padctl_xlate(struct device *dev, · line 686

Quoted 8 lines
drivers/pinctrl/pinctrl-tegra-xusb.c +1 -1
@@ -680,7 +680,7 @@ static struct phy *tegra_xusb_padctl_xlate(struct device *dev,
 	if (args->args_count <= 0)
 		return ERR_PTR(-EINVAL);
 
-	if (index > ARRAY_SIZE(padctl->phys))
+	if (index >= ARRAY_SIZE(padctl->phys))
 		return ERR_PTR(-EINVAL);
 
 	return padctl->phys[index];

Good catch!