Skip to content

Commit 31c8025

Browse files
David Brazdilrobherring
authored andcommitted
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. Fixes: f3cfd13 ("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> Acked-by: Will Deacon <will@kernel.org> Link: https://lore.kernel.org/r/20210917131423.2760155-1-dbrazdil@google.com Signed-off-by: Rob Herring <robh@kernel.org>
1 parent c8087ad commit 31c8025

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/of/device.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ of_dma_set_restricted_buffer(struct device *dev, struct device_node *np)
8585
break;
8686
}
8787

88-
if (i != count && of_reserved_mem_device_init_by_idx(dev, of_node, i))
88+
/*
89+
* Attempt to initialize a restricted-dma-pool region if one was found.
90+
* Note that count can hold a negative error code.
91+
*/
92+
if (i < count && of_reserved_mem_device_init_by_idx(dev, of_node, i))
8993
dev_warn(dev, "failed to initialise \"restricted-dma-pool\" memory node\n");
9094
}
9195

0 commit comments

Comments
 (0)