mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-01-18 16:56:09 +07:00
drm: Declare that create drm_mm nodes with size 0 is illegal
At a higher level, all objects are created with definite size i.e. 0 is illegal. In forthcoming patches, this assumption is dependent upon in the drm_mm range manager, i.e. trying to create a drm_mm node with size 0 will have undefined behaviour. Add a couple of WARNs upon creating the drm_mm node to prevent later bugs. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/1470248788-30873-1-git-send-email-chris@chris-wilson.co.uk
This commit is contained in:
parent
a3ccc46166
commit
aafdcfd3f9
@ -250,6 +250,9 @@ int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node)
|
|||||||
struct drm_mm_node *hole;
|
struct drm_mm_node *hole;
|
||||||
u64 hole_start, hole_end;
|
u64 hole_start, hole_end;
|
||||||
|
|
||||||
|
if (WARN_ON(node->size == 0))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
end = node->start + node->size;
|
end = node->start + node->size;
|
||||||
|
|
||||||
/* Find the relevant hole to add our node to */
|
/* Find the relevant hole to add our node to */
|
||||||
@ -317,6 +320,9 @@ int drm_mm_insert_node_generic(struct drm_mm *mm, struct drm_mm_node *node,
|
|||||||
{
|
{
|
||||||
struct drm_mm_node *hole_node;
|
struct drm_mm_node *hole_node;
|
||||||
|
|
||||||
|
if (WARN_ON(size == 0))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
hole_node = drm_mm_search_free_generic(mm, size, alignment,
|
hole_node = drm_mm_search_free_generic(mm, size, alignment,
|
||||||
color, sflags);
|
color, sflags);
|
||||||
if (!hole_node)
|
if (!hole_node)
|
||||||
@ -419,6 +425,9 @@ int drm_mm_insert_node_in_range_generic(struct drm_mm *mm, struct drm_mm_node *n
|
|||||||
{
|
{
|
||||||
struct drm_mm_node *hole_node;
|
struct drm_mm_node *hole_node;
|
||||||
|
|
||||||
|
if (WARN_ON(size == 0))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
hole_node = drm_mm_search_free_in_range_generic(mm,
|
hole_node = drm_mm_search_free_in_range_generic(mm,
|
||||||
size, alignment, color,
|
size, alignment, color,
|
||||||
start, end, sflags);
|
start, end, sflags);
|
||||||
|
Loading…
Reference in New Issue
Block a user