* [PATCH] of: restricted dma: Fix condition for rmem init
@ 2021-09-17 13:14 David Brazdil
2021-09-17 14:51 ` Will Deacon
2021-09-17 20:58 ` Rob Herring
0 siblings, 2 replies; 3+ messages in thread
From: David Brazdil @ 2021-09-17 13:14 UTC (permalink / raw)
To: devicetree
Cc: Rob Herring, Frank Rowand, Will Deacon, Konrad Rzeszutek Wilk,
linux-kernel, David Brazdil
of_dma_set_restricted_buffer fails to handle negative return values from
of_property_count_elems_of_size, e.g. when the property does not exist.
This results in an attempt to assign a non-existent reserved memory
region to the device and a warning being printed. Fix the condition to
take negative values into account.
Fixes: f3cfd136aef0 ("of: restricted dma: Don't fail device probe on
rmem init failure")
Cc: Will Deacon <will@kernel.org>
Signed-off-by: David Brazdil <dbrazdil@google.com>
---
drivers/of/device.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/of/device.c b/drivers/of/device.c
index 5b043ee30824..b0800c260f64 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -85,7 +85,11 @@ of_dma_set_restricted_buffer(struct device *dev, struct device_node *np)
break;
}
- if (i != count && of_reserved_mem_device_init_by_idx(dev, of_node, i))
+ /*
+ * Attempt to initialize a restricted-dma-pool region if one was found.
+ * Note that count can hold a negative error code.
+ */
+ if (i < count && of_reserved_mem_device_init_by_idx(dev, of_node, i))
dev_warn(dev, "failed to initialise \"restricted-dma-pool\" memory node\n");
}
--
2.33.0.464.g1972c5931b-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] of: restricted dma: Fix condition for rmem init
2021-09-17 13:14 [PATCH] of: restricted dma: Fix condition for rmem init David Brazdil
@ 2021-09-17 14:51 ` Will Deacon
2021-09-17 20:58 ` Rob Herring
1 sibling, 0 replies; 3+ messages in thread
From: Will Deacon @ 2021-09-17 14:51 UTC (permalink / raw)
To: David Brazdil
Cc: devicetree, Rob Herring, Frank Rowand, Konrad Rzeszutek Wilk,
linux-kernel
On Fri, Sep 17, 2021 at 02:14:23PM +0100, David Brazdil wrote:
> of_dma_set_restricted_buffer fails to handle negative return values from
> of_property_count_elems_of_size, e.g. when the property does not exist.
> This results in an attempt to assign a non-existent reserved memory
> region to the device and a warning being printed. Fix the condition to
> take negative values into account.
>
> Fixes: f3cfd136aef0 ("of: restricted dma: Don't fail device probe on
> rmem init failure")
> Cc: Will Deacon <will@kernel.org>
> Signed-off-by: David Brazdil <dbrazdil@google.com>
> ---
> drivers/of/device.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/of/device.c b/drivers/of/device.c
> index 5b043ee30824..b0800c260f64 100644
> --- a/drivers/of/device.c
> +++ b/drivers/of/device.c
> @@ -85,7 +85,11 @@ of_dma_set_restricted_buffer(struct device *dev, struct device_node *np)
> break;
> }
>
> - if (i != count && of_reserved_mem_device_init_by_idx(dev, of_node, i))
> + /*
> + * Attempt to initialize a restricted-dma-pool region if one was found.
> + * Note that count can hold a negative error code.
> + */
> + if (i < count && of_reserved_mem_device_init_by_idx(dev, of_node, i))
> dev_warn(dev, "failed to initialise \"restricted-dma-pool\" memory node\n");
/me shakes fist at of_property_count_elems_of_size()
Thanks for the fix:
Acked-by: Will Deacon <will@kernel.org>
Will
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] of: restricted dma: Fix condition for rmem init
2021-09-17 13:14 [PATCH] of: restricted dma: Fix condition for rmem init David Brazdil
2021-09-17 14:51 ` Will Deacon
@ 2021-09-17 20:58 ` Rob Herring
1 sibling, 0 replies; 3+ messages in thread
From: Rob Herring @ 2021-09-17 20:58 UTC (permalink / raw)
To: David Brazdil
Cc: Rob Herring, devicetree, Konrad Rzeszutek Wilk, Frank Rowand,
Will Deacon, linux-kernel
On Fri, 17 Sep 2021 14:14:23 +0100, David Brazdil wrote:
> of_dma_set_restricted_buffer fails to handle negative return values from
> of_property_count_elems_of_size, e.g. when the property does not exist.
> This results in an attempt to assign a non-existent reserved memory
> region to the device and a warning being printed. Fix the condition to
> take negative values into account.
>
> Fixes: f3cfd136aef0 ("of: restricted dma: Don't fail device probe on
> rmem init failure")
> Cc: Will Deacon <will@kernel.org>
> Signed-off-by: David Brazdil <dbrazdil@google.com>
> ---
> drivers/of/device.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
Applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-17 20:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-17 13:14 [PATCH] of: restricted dma: Fix condition for rmem init David Brazdil
2021-09-17 14:51 ` Will Deacon
2021-09-17 20:58 ` Rob Herring
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).