of: restricted dma: Fix condition for rmem init
PATCH 1/1 of: restricted dma: Fix condition for rmem init
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.
rmem init failure")
--- drivers/of/device.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/of/device.c +5 -1
@@ -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" ); }
Signature · 1 line
2.33.0.464.g1972c5931b-goog
Quoted 19 lines · David Brazdil
of_dma_set_restricted_bufferfails to handle negative return values fromof_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 onrmem init failure")
Cc Will Deacon <[email protected]>Signed-off-by David Brazdil <[email protected]>--- drivers/of/device.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/of/device.c +0
-0
drivers/of/device.c of_dma_set_restricted_buffer(struct device *dev, struct device_node *np) · line 93
Quoted 10 lines
drivers/of/device.c +5
-1@@ -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:
Will
Quoted 6 lines · David Brazdil
of_dma_set_restricted_bufferfails to handle negative return values fromof_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.
Quoted 8 lines
Fixes f3cfd136aef0 ("of: restricted dma: Don't fail device probe onrmem init failure")
Cc Will Deacon <[email protected]>Signed-off-by David Brazdil <[email protected]>--- drivers/of/device.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Applied, thanks!