* [PATCH 1/3] pinctrl: samsung: Constify wakeup driver specific data
@ 2017-05-23 18:41 Krzysztof Kozlowski
2017-05-23 18:41 ` [PATCH 2/3] pinctrl: samsung: Handle memory allocation failure during wakeup banks init Krzysztof Kozlowski
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2017-05-23 18:41 UTC (permalink / raw)
To: Tomasz Figa, Krzysztof Kozlowski, Sylwester Nawrocki,
Linus Walleij, Kukjin Kim, linux-arm-kernel, linux-samsung-soc,
linux-gpio, linux-kernel
Static exynos_irq_chip structures, containing driver specific data, are
referenced only through opaque data pointer in const of_device_id table.
The contents of pointed memory (exynos_irq_chip structure itself) is
then copied with kmemdup() during wakeup initialization so
exynos_irq_chip can be made const for code safenes.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
drivers/pinctrl/samsung/pinctrl-exynos.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c
index 7b0e6cc35e04..cdea07af308a 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
@@ -387,7 +387,7 @@ static int exynos_wkup_irq_set_wake(struct irq_data *irqd, unsigned int on)
/*
* irq_chip for wakeup interrupts
*/
-static struct exynos_irq_chip exynos4210_wkup_irq_chip __initdata = {
+static const struct exynos_irq_chip exynos4210_wkup_irq_chip __initconst = {
.chip = {
.name = "exynos4210_wkup_irq_chip",
.irq_unmask = exynos_irq_unmask,
@@ -403,7 +403,7 @@ static struct exynos_irq_chip exynos4210_wkup_irq_chip __initdata = {
.eint_pend = EXYNOS_WKUP_EPEND_OFFSET,
};
-static struct exynos_irq_chip exynos7_wkup_irq_chip __initdata = {
+static const struct exynos_irq_chip exynos7_wkup_irq_chip __initconst = {
.chip = {
.name = "exynos7_wkup_irq_chip",
.irq_unmask = exynos_irq_unmask,
--
2.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] pinctrl: samsung: Handle memory allocation failure during wakeup banks init
2017-05-23 18:41 [PATCH 1/3] pinctrl: samsung: Constify wakeup driver specific data Krzysztof Kozlowski
@ 2017-05-23 18:41 ` Krzysztof Kozlowski
2017-05-23 18:41 ` [PATCH 3/3] pinctrl: samsung: Explicitly cast pointer returned by of_iomap() to iomem Krzysztof Kozlowski
2017-05-29 9:34 ` [PATCH 1/3] pinctrl: samsung: Constify wakeup driver specific data Linus Walleij
2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2017-05-23 18:41 UTC (permalink / raw)
To: Tomasz Figa, Krzysztof Kozlowski, Sylwester Nawrocki,
Linus Walleij, Kukjin Kim, linux-arm-kernel, linux-samsung-soc,
linux-gpio, linux-kernel
Check if kmemdup failed during wakeup banks initialization. Otherwise
NULL pointer would be stored under "irq_chip" member of bank and later
dereferenced in interrupt handler.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
drivers/pinctrl/samsung/pinctrl-exynos.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c
index cdea07af308a..66122627b3ed 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
@@ -503,6 +503,8 @@ static int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
if (match) {
irq_chip = kmemdup(match->data,
sizeof(*irq_chip), GFP_KERNEL);
+ if (!irq_chip)
+ return -ENOMEM;
wkup_np = np;
break;
}
--
2.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] pinctrl: samsung: Explicitly cast pointer returned by of_iomap() to iomem
2017-05-23 18:41 [PATCH 1/3] pinctrl: samsung: Constify wakeup driver specific data Krzysztof Kozlowski
2017-05-23 18:41 ` [PATCH 2/3] pinctrl: samsung: Handle memory allocation failure during wakeup banks init Krzysztof Kozlowski
@ 2017-05-23 18:41 ` Krzysztof Kozlowski
2017-05-29 9:34 ` [PATCH 1/3] pinctrl: samsung: Constify wakeup driver specific data Linus Walleij
2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2017-05-23 18:41 UTC (permalink / raw)
To: Tomasz Figa, Krzysztof Kozlowski, Sylwester Nawrocki,
Linus Walleij, Kukjin Kim, linux-arm-kernel, linux-samsung-soc,
linux-gpio, linux-kernel
For S5Pv210 retention control, the driver stores the iomem pointer from
of_iomap() under void pointer priv member. This makes sparse unhappy:
drivers/pinctrl/samsung/pinctrl-exynos.c:664:36: warning: incorrect type in argument 1 (different address spaces)
drivers/pinctrl/samsung/pinctrl-exynos.c:664:36: expected void const volatile [noderef] <asn:2>*addr
drivers/pinctrl/samsung/pinctrl-exynos.c:664:36: got void *
The iomem pointer is used safely (stored under priv by
s5pv210_retention_init(), used by s5pv210_retention_disable() thus we
can add explicit casts to iomem silence the warning.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
drivers/pinctrl/samsung/pinctrl-exynos.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c
index 66122627b3ed..a870af943bc7 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
@@ -656,7 +656,7 @@ static void exynos_pinctrl_resume(struct samsung_pinctrl_drv_data *drvdata)
static void s5pv210_retention_disable(struct samsung_pinctrl_drv_data *drvdata)
{
- void *clk_base = drvdata->retention_ctrl->priv;
+ void __iomem *clk_base = (void __iomem *)drvdata->retention_ctrl->priv;
u32 tmp;
tmp = __raw_readl(clk_base + S5P_OTHERS);
@@ -671,7 +671,7 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data *drvdata,
{
struct samsung_retention_ctrl *ctrl;
struct device_node *np;
- void *clk_base;
+ void __iomem *clk_base;
ctrl = devm_kzalloc(drvdata->dev, sizeof(*ctrl), GFP_KERNEL);
if (!ctrl)
@@ -690,7 +690,7 @@ s5pv210_retention_init(struct samsung_pinctrl_drv_data *drvdata,
return ERR_PTR(-EINVAL);
}
- ctrl->priv = clk_base;
+ ctrl->priv = (void __force *)clk_base;
ctrl->disable = s5pv210_retention_disable;
return ctrl;
--
2.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] pinctrl: samsung: Constify wakeup driver specific data
2017-05-23 18:41 [PATCH 1/3] pinctrl: samsung: Constify wakeup driver specific data Krzysztof Kozlowski
2017-05-23 18:41 ` [PATCH 2/3] pinctrl: samsung: Handle memory allocation failure during wakeup banks init Krzysztof Kozlowski
2017-05-23 18:41 ` [PATCH 3/3] pinctrl: samsung: Explicitly cast pointer returned by of_iomap() to iomem Krzysztof Kozlowski
@ 2017-05-29 9:34 ` Linus Walleij
2 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2017-05-29 9:34 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Tomasz Figa, Sylwester Nawrocki, Kukjin Kim, linux-arm-kernel,
linux-samsung-soc, linux-gpio, linux-kernel
On Tue, May 23, 2017 at 8:41 PM, Krzysztof Kozlowski <krzk@kernel.org> wrote:
> Static exynos_irq_chip structures, containing driver specific data, are
> referenced only through opaque data pointer in const of_device_id table.
> The contents of pointed memory (exynos_irq_chip structure itself) is
> then copied with kmemdup() during wakeup initialization so
> exynos_irq_chip can be made const for code safenes.
>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
All looks good to me, Acked-by.
Expecting to get this in a pull request.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-05-29 9:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-23 18:41 [PATCH 1/3] pinctrl: samsung: Constify wakeup driver specific data Krzysztof Kozlowski
2017-05-23 18:41 ` [PATCH 2/3] pinctrl: samsung: Handle memory allocation failure during wakeup banks init Krzysztof Kozlowski
2017-05-23 18:41 ` [PATCH 3/3] pinctrl: samsung: Explicitly cast pointer returned by of_iomap() to iomem Krzysztof Kozlowski
2017-05-29 9:34 ` [PATCH 1/3] pinctrl: samsung: Constify wakeup driver specific data Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).