* [PATCH 1/2] gpio: stm32: cosmetic: cleanup gpio_stm32_probe
@ 2020-09-09 16:28 Patrick Delaunay
2020-09-09 16:28 ` [PATCH 2/2] gpio: stm32: check result of ofnode_phandle_args Patrick Delaunay
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Patrick Delaunay @ 2020-09-09 16:28 UTC (permalink / raw)
To: u-boot
Move the variables definition at the beggining of the function
gpio_stm32_probe().
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
drivers/gpio/stm32_gpio.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/gpio/stm32_gpio.c b/drivers/gpio/stm32_gpio.c
index 5bff27f75b..aa70b1d2a9 100644
--- a/drivers/gpio/stm32_gpio.c
+++ b/drivers/gpio/stm32_gpio.c
@@ -273,9 +273,12 @@ static const struct dm_gpio_ops gpio_stm32_ops = {
static int gpio_stm32_probe(struct udevice *dev)
{
struct stm32_gpio_priv *priv = dev_get_priv(dev);
+ struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
+ struct ofnode_phandle_args args;
+ const char *name;
struct clk clk;
fdt_addr_t addr;
- int ret;
+ int ret, i;
addr = dev_read_addr(dev);
if (addr == FDT_ADDR_T_NONE)
@@ -283,11 +286,6 @@ static int gpio_stm32_probe(struct udevice *dev)
priv->regs = (struct stm32_gpio_regs *)addr;
- struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
- struct ofnode_phandle_args args;
- const char *name;
- int i;
-
name = dev_read_string(dev, "st,bank-name");
if (!name)
return -EINVAL;
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] gpio: stm32: check result of ofnode_phandle_args
2020-09-09 16:28 [PATCH 1/2] gpio: stm32: cosmetic: cleanup gpio_stm32_probe Patrick Delaunay
@ 2020-09-09 16:28 ` Patrick Delaunay
2020-10-02 9:35 ` Patrice CHOTARD
2020-10-02 13:14 ` Patrick DELAUNAY
2020-10-02 9:34 ` [PATCH 1/2] gpio: stm32: cosmetic: cleanup gpio_stm32_probe Patrice CHOTARD
2020-10-02 13:13 ` Patrick DELAUNAY
2 siblings, 2 replies; 6+ messages in thread
From: Patrick Delaunay @ 2020-09-09 16:28 UTC (permalink / raw)
To: u-boot
Add test on the size of ofnode_phandle_args result to avoid access
to uninitialized elements in args[] field.
This patch avoids the issue when gpio-ranges cell size is not 3 as
expected, for example:
gpio-ranges = <&pinctrl 0>;
instead of
gpio-ranges = <&pinctrl 0 112 16>;
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
drivers/gpio/stm32_gpio.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/gpio/stm32_gpio.c b/drivers/gpio/stm32_gpio.c
index aa70b1d2a9..473e364796 100644
--- a/drivers/gpio/stm32_gpio.c
+++ b/drivers/gpio/stm32_gpio.c
@@ -295,6 +295,9 @@ static int gpio_stm32_probe(struct udevice *dev)
ret = dev_read_phandle_with_args(dev, "gpio-ranges",
NULL, 3, i, &args);
+ if (!ret && args.args_count < 3)
+ return -EINVAL;
+
if (ret == -ENOENT) {
uc_priv->gpio_count = STM32_GPIOS_PER_BANK;
priv->gpio_range = GENMASK(STM32_GPIOS_PER_BANK - 1, 0);
@@ -308,6 +311,8 @@ static int gpio_stm32_probe(struct udevice *dev)
ret = dev_read_phandle_with_args(dev, "gpio-ranges", NULL, 3,
++i, &args);
+ if (!ret && args.args_count < 3)
+ return -EINVAL;
}
dev_dbg(dev, "addr = 0x%p bank_name = %s gpio_count = %d gpio_range = 0x%x\n",
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/2] gpio: stm32: cosmetic: cleanup gpio_stm32_probe
2020-09-09 16:28 [PATCH 1/2] gpio: stm32: cosmetic: cleanup gpio_stm32_probe Patrick Delaunay
2020-09-09 16:28 ` [PATCH 2/2] gpio: stm32: check result of ofnode_phandle_args Patrick Delaunay
@ 2020-10-02 9:34 ` Patrice CHOTARD
2020-10-02 13:13 ` Patrick DELAUNAY
2 siblings, 0 replies; 6+ messages in thread
From: Patrice CHOTARD @ 2020-10-02 9:34 UTC (permalink / raw)
To: u-boot
Hi Patrick
On 9/9/20 6:28 PM, Patrick Delaunay wrote:
> Move the variables definition at the beggining of the function
> gpio_stm32_probe().
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> drivers/gpio/stm32_gpio.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpio/stm32_gpio.c b/drivers/gpio/stm32_gpio.c
> index 5bff27f75b..aa70b1d2a9 100644
> --- a/drivers/gpio/stm32_gpio.c
> +++ b/drivers/gpio/stm32_gpio.c
> @@ -273,9 +273,12 @@ static const struct dm_gpio_ops gpio_stm32_ops = {
> static int gpio_stm32_probe(struct udevice *dev)
> {
> struct stm32_gpio_priv *priv = dev_get_priv(dev);
> + struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
> + struct ofnode_phandle_args args;
> + const char *name;
> struct clk clk;
> fdt_addr_t addr;
> - int ret;
> + int ret, i;
>
> addr = dev_read_addr(dev);
> if (addr == FDT_ADDR_T_NONE)
> @@ -283,11 +286,6 @@ static int gpio_stm32_probe(struct udevice *dev)
>
> priv->regs = (struct stm32_gpio_regs *)addr;
>
> - struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
> - struct ofnode_phandle_args args;
> - const char *name;
> - int i;
> -
> name = dev_read_string(dev, "st,bank-name");
> if (!name)
> return -EINVAL;
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] gpio: stm32: check result of ofnode_phandle_args
2020-09-09 16:28 ` [PATCH 2/2] gpio: stm32: check result of ofnode_phandle_args Patrick Delaunay
@ 2020-10-02 9:35 ` Patrice CHOTARD
2020-10-02 13:14 ` Patrick DELAUNAY
1 sibling, 0 replies; 6+ messages in thread
From: Patrice CHOTARD @ 2020-10-02 9:35 UTC (permalink / raw)
To: u-boot
Hi Patrick
On 9/9/20 6:28 PM, Patrick Delaunay wrote:
> Add test on the size of ofnode_phandle_args result to avoid access
> to uninitialized elements in args[] field.
>
> This patch avoids the issue when gpio-ranges cell size is not 3 as
> expected, for example:
> gpio-ranges = <&pinctrl 0>;
> instead of
> gpio-ranges = <&pinctrl 0 112 16>;
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> drivers/gpio/stm32_gpio.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpio/stm32_gpio.c b/drivers/gpio/stm32_gpio.c
> index aa70b1d2a9..473e364796 100644
> --- a/drivers/gpio/stm32_gpio.c
> +++ b/drivers/gpio/stm32_gpio.c
> @@ -295,6 +295,9 @@ static int gpio_stm32_probe(struct udevice *dev)
> ret = dev_read_phandle_with_args(dev, "gpio-ranges",
> NULL, 3, i, &args);
>
> + if (!ret && args.args_count < 3)
> + return -EINVAL;
> +
> if (ret == -ENOENT) {
> uc_priv->gpio_count = STM32_GPIOS_PER_BANK;
> priv->gpio_range = GENMASK(STM32_GPIOS_PER_BANK - 1, 0);
> @@ -308,6 +311,8 @@ static int gpio_stm32_probe(struct udevice *dev)
>
> ret = dev_read_phandle_with_args(dev, "gpio-ranges", NULL, 3,
> ++i, &args);
> + if (!ret && args.args_count < 3)
> + return -EINVAL;
> }
>
> dev_dbg(dev, "addr = 0x%p bank_name = %s gpio_count = %d gpio_range = 0x%x\n",
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] gpio: stm32: cosmetic: cleanup gpio_stm32_probe
2020-09-09 16:28 [PATCH 1/2] gpio: stm32: cosmetic: cleanup gpio_stm32_probe Patrick Delaunay
2020-09-09 16:28 ` [PATCH 2/2] gpio: stm32: check result of ofnode_phandle_args Patrick Delaunay
2020-10-02 9:34 ` [PATCH 1/2] gpio: stm32: cosmetic: cleanup gpio_stm32_probe Patrice CHOTARD
@ 2020-10-02 13:13 ` Patrick DELAUNAY
2 siblings, 0 replies; 6+ messages in thread
From: Patrick DELAUNAY @ 2020-10-02 13:13 UTC (permalink / raw)
To: u-boot
Hi,
> From: Patrick DELAUNAY <patrick.delaunay@st.com>
> Sent: mercredi 9 septembre 2020 18:29
>
> Move the variables definition at the beggining of the function gpio_stm32_probe().
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> drivers/gpio/stm32_gpio.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
Applied to u-boot-stm/next, thanks!
Regards
Patrick
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] gpio: stm32: check result of ofnode_phandle_args
2020-09-09 16:28 ` [PATCH 2/2] gpio: stm32: check result of ofnode_phandle_args Patrick Delaunay
2020-10-02 9:35 ` Patrice CHOTARD
@ 2020-10-02 13:14 ` Patrick DELAUNAY
1 sibling, 0 replies; 6+ messages in thread
From: Patrick DELAUNAY @ 2020-10-02 13:14 UTC (permalink / raw)
To: u-boot
Hi,
> From: Patrick DELAUNAY <patrick.delaunay@st.com>
>
> Add test on the size of ofnode_phandle_args result to avoid access to uninitialized
> elements in args[] field.
>
> This patch avoids the issue when gpio-ranges cell size is not 3 as expected, for
> example:
> gpio-ranges = <&pinctrl 0>;
> instead of
> gpio-ranges = <&pinctrl 0 112 16>;
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> drivers/gpio/stm32_gpio.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
Applied to u-boot-stm/next, thanks!
Regards
Patrick
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-10-02 13:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-09 16:28 [PATCH 1/2] gpio: stm32: cosmetic: cleanup gpio_stm32_probe Patrick Delaunay
2020-09-09 16:28 ` [PATCH 2/2] gpio: stm32: check result of ofnode_phandle_args Patrick Delaunay
2020-10-02 9:35 ` Patrice CHOTARD
2020-10-02 13:14 ` Patrick DELAUNAY
2020-10-02 9:34 ` [PATCH 1/2] gpio: stm32: cosmetic: cleanup gpio_stm32_probe Patrice CHOTARD
2020-10-02 13:13 ` Patrick DELAUNAY
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.