Re: [PATCH] drm: Declare that create drm_mm nodes with size 0 is illegal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 3, 2016 at 8:26 PM, Chris Wilson <chris@xxxxxxxxxxxxxxxxxx> wrote:
> 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@xxxxxxxxxxxxxxxxxx>
> ---
>  drivers/gpu/drm/drm_mm.c | 9 +++++++++
>  1 file changed, 9 insertions(+)

Reviewed-by: David Herrmann <dh.herrmann@xxxxxxxxx>

Thanks
David

> diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
> index cb39f45d6a16..e8c15795386d 100644
> --- a/drivers/gpu/drm/drm_mm.c
> +++ b/drivers/gpu/drm/drm_mm.c
> @@ -185,6 +185,9 @@ int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node)
>
>         BUG_ON(node == NULL);
>
> +       if (WARN_ON(node->size == 0))
> +               return -EINVAL;
> +
>         end = node->start + node->size;
>
>         /* Find the relevant hole to add our node to */
> @@ -239,6 +242,9 @@ int drm_mm_insert_node_generic(struct drm_mm *mm, struct drm_mm_node *node,
>  {
>         struct drm_mm_node *hole_node;
>
> +       if (WARN_ON(size == 0))
> +               return -EINVAL;
> +
>         hole_node = drm_mm_search_free_generic(mm, size, alignment,
>                                                color, sflags);
>         if (!hole_node)
> @@ -340,6 +346,9 @@ int drm_mm_insert_node_in_range_generic(struct drm_mm *mm, struct drm_mm_node *n
>  {
>         struct drm_mm_node *hole_node;
>
> +       if (WARN_ON(size == 0))
> +               return -EINVAL;
> +
>         hole_node = drm_mm_search_free_in_range_generic(mm,
>                                                         size, alignment, color,
>                                                         start, end, sflags);
> --
> 2.8.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux