2019-05-20 13:09:42

by Charles Keepax

[permalink] [raw]
Subject: [PATCH 1/4 RESEND] mfd: arizona: fix undefined behavior

From: Arnd Bergmann <[email protected]>

When the driver is used with a subdevice that is disabled in the
kernel configuration, clang gets a little confused about the
control flow and fails to notice that n_subdevs is only
uninitialized when subdevs is NULL, and we check for that,
leading to a false-positive warning:

drivers/mfd/arizona-core.c:1423:19: error: variable 'n_subdevs' is uninitialized when used here
[-Werror,-Wuninitialized]
subdevs, n_subdevs, NULL, 0, NULL);
^~~~~~~~~
drivers/mfd/arizona-core.c:999:15: note: initialize the variable 'n_subdevs' to silence this warning
int n_subdevs, ret, i;
^
= 0

Ideally, we would rearrange the code to avoid all those early
initializations and have an explicit exit in each disabled case,
but it's much easier to chicken out and add one more initialization
here to shut up the warning.

Signed-off-by: Arnd Bergmann <[email protected]>
Reviewed-by: Nathan Chancellor <[email protected]>
Signed-off-by: Charles Keepax <[email protected]>
---
drivers/mfd/arizona-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 27b61639cdc7e..0ca0fc9a67fd9 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -996,7 +996,7 @@ int arizona_dev_init(struct arizona *arizona)
unsigned int reg, val;
int (*apply_patch)(struct arizona *) = NULL;
const struct mfd_cell *subdevs = NULL;
- int n_subdevs, ret, i;
+ int n_subdevs = 0, ret, i;

dev_set_drvdata(arizona->dev, arizona);
mutex_init(&arizona->clk_lock);
--
2.11.0



2019-05-20 13:13:45

by Charles Keepax

[permalink] [raw]
Subject: [PATCH 2/4 RESEND] mfd: madera: Fix bad reference to pinctrl.txt file

From: Otto Sabart <[email protected]>

The pinctrl.txt file was converted into reStructuredText and moved into
driver-api folder. This patch updates the broken reference.

Fixes: 5a9b73832e9e ("pinctrl.txt: move it to the driver-api book")
Signed-off-by: Otto Sabart <[email protected]>
Signed-off-by: Charles Keepax <[email protected]>
---
include/linux/mfd/madera/pdata.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/mfd/madera/pdata.h b/include/linux/mfd/madera/pdata.h
index 8dc852402dbb1..dd00ab824e5be 100644
--- a/include/linux/mfd/madera/pdata.h
+++ b/include/linux/mfd/madera/pdata.h
@@ -34,7 +34,8 @@ struct madera_codec_pdata;
* @micvdd: Substruct of pdata for the MICVDD regulator
* @irq_flags: Mode for primary IRQ (defaults to active low)
* @gpio_base: Base GPIO number
- * @gpio_configs: Array of GPIO configurations (See Documentation/pinctrl.txt)
+ * @gpio_configs: Array of GPIO configurations (See
+ * Documentation/driver-api/pinctl.rst)
* @n_gpio_configs: Number of entries in gpio_configs
* @gpsw: General purpose switch mode setting. Depends on the external
* hardware connected to the switch. (See the SW1_MODE field
--
2.11.0


2019-05-27 13:54:01

by Mauro Carvalho Chehab

[permalink] [raw]
Subject: Re: [PATCH 2/4 RESEND] mfd: madera: Fix bad reference to pinctrl.txt file

Em Mon, 20 May 2019 10:06:26 +0100
Charles Keepax <[email protected]> escreveu:

> From: Otto Sabart <[email protected]>
>
> The pinctrl.txt file was converted into reStructuredText and moved into
> driver-api folder. This patch updates the broken reference.
>
> Fixes: 5a9b73832e9e ("pinctrl.txt: move it to the driver-api book")
> Signed-off-by: Otto Sabart <[email protected]>
> Signed-off-by: Charles Keepax <[email protected]>

Reviewed-by: Mauro Carvalho Chehab <[email protected]>

> ---
> include/linux/mfd/madera/pdata.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/mfd/madera/pdata.h b/include/linux/mfd/madera/pdata.h
> index 8dc852402dbb1..dd00ab824e5be 100644
> --- a/include/linux/mfd/madera/pdata.h
> +++ b/include/linux/mfd/madera/pdata.h
> @@ -34,7 +34,8 @@ struct madera_codec_pdata;
> * @micvdd: Substruct of pdata for the MICVDD regulator
> * @irq_flags: Mode for primary IRQ (defaults to active low)
> * @gpio_base: Base GPIO number
> - * @gpio_configs: Array of GPIO configurations (See Documentation/pinctrl.txt)
> + * @gpio_configs: Array of GPIO configurations (See
> + * Documentation/driver-api/pinctl.rst)
> * @n_gpio_configs: Number of entries in gpio_configs
> * @gpsw: General purpose switch mode setting. Depends on the external
> * hardware connected to the switch. (See the SW1_MODE field



Thanks,
Mauro

2019-06-12 08:54:25

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH 1/4 RESEND] mfd: arizona: fix undefined behavior

On Mon, 20 May 2019, Charles Keepax wrote:

> From: Arnd Bergmann <[email protected]>
>
> When the driver is used with a subdevice that is disabled in the
> kernel configuration, clang gets a little confused about the
> control flow and fails to notice that n_subdevs is only
> uninitialized when subdevs is NULL, and we check for that,
> leading to a false-positive warning:
>
> drivers/mfd/arizona-core.c:1423:19: error: variable 'n_subdevs' is uninitialized when used here
> [-Werror,-Wuninitialized]
> subdevs, n_subdevs, NULL, 0, NULL);
> ^~~~~~~~~
> drivers/mfd/arizona-core.c:999:15: note: initialize the variable 'n_subdevs' to silence this warning
> int n_subdevs, ret, i;
> ^
> = 0
>
> Ideally, we would rearrange the code to avoid all those early
> initializations and have an explicit exit in each disabled case,
> but it's much easier to chicken out and add one more initialization
> here to shut up the warning.
>
> Signed-off-by: Arnd Bergmann <[email protected]>
> Reviewed-by: Nathan Chancellor <[email protected]>
> Signed-off-by: Charles Keepax <[email protected]>
> ---
> drivers/mfd/arizona-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

2019-06-12 08:54:30

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH 2/4 RESEND] mfd: madera: Fix bad reference to pinctrl.txt file

On Mon, 20 May 2019, Charles Keepax wrote:

> From: Otto Sabart <[email protected]>
>
> The pinctrl.txt file was converted into reStructuredText and moved into
> driver-api folder. This patch updates the broken reference.
>
> Fixes: 5a9b73832e9e ("pinctrl.txt: move it to the driver-api book")
> Signed-off-by: Otto Sabart <[email protected]>
> Signed-off-by: Charles Keepax <[email protected]>
> ---
> include/linux/mfd/madera/pdata.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)

Applied, thanks.

--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog