Skip to contentSkip to conversation

drm/udl: fix error-path when damage-req fails

PATCH Superseded David Herrmann 4 participants 29 messages Jan 20, 2014 – Feb 5, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/7 drm/udl: fix error-path when damage-req fails

We need to call dma_buf_end_cpu_access() in case a damage-request. Unlikely, but might happen during device unplug.

---
 drivers/gpu/drm/udl/udl_fb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_fb.c +2 -1
index dbadd49..50f564d 100644
@@ -421,9 +421,10 @@ static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb,
 				  clips[i].x2 - clips[i].x1,
 				  clips[i].y2 - clips[i].y1);
 		if (ret)
-			goto unlock;
+			goto end_access;
 	}
 
+end_access:
 	if (ufb->obj->base.import_attach) {
 		dma_buf_end_cpu_access(ufb->obj->base.import_attach->dmabuf,
 				       0, ufb->obj->base.size,
Signature · 1 line
1.8.5.3
#1 lore raw

PATCH 2/7 drm/udl: fix Bpp calculation in dumb_create()

Probably a typo.. we obviously need "(bpp + 7) / 8" instead of "(bpp + 1) / 8". Unlikely to be hit in any sane code, but lets be safe.

---
 drivers/gpu/drm/udl/udl_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_gem.c +1 -1
index 8d67b94..df963a1 100644
@@ -60,7 +60,7 @@ int udl_dumb_create(struct drm_file *file,
 		    struct drm_device *dev,
 		    struct drm_mode_create_dumb *args)
 {
-	args->pitch = args->width * ((args->bpp + 1) / 8);
+	args->pitch = args->width * ((args->bpp + 7) / 8);
 	args->size = args->pitch * args->height;
 	return udl_gem_create(file, dev,
 			      args->size, &args->handle);
Signature · 1 line
1.8.5.3
#2 lore raw

Re: [PATCH 2/7] drm/udl: fix Bpp calculation in dumb_create()

Quoted 13 lines · David Herrmann

Probably a typo.. we obviously need "(bpp + 7) / 8" instead of "(bpp + 1) / 8". Unlikely to be hit in any sane code, but lets be safe.

---
 drivers/gpu/drm/udl/udl_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_gem.c +0 -0
index 8d67b94..df963a1 100644

drivers/gpu/drm/udl/udl_gem.c int udl_dumb_create(struct drm_file *file, · line 63

Quoted 5 lines
drivers/gpu/drm/udl/udl_gem.c +1 -1
@@ -60,7 +60,7 @@ int udl_dumb_create(struct drm_file *file,
 		    struct drm_device *dev,
 		    struct drm_mode_create_dumb *args)
 {
-	args->pitch = args->width * ((args->bpp + 1) / 8);
+	args->pitch = args->width * ((args->bpp + 7) / 8);

DIV_ROUND_UP?

Quoted 6 lines
drivers/gpu/drm/udl/udl_gem.c +0 -0
 	args->size = args->pitch * args->height;
 	return udl_gem_create(file, dev,
 			      args->size, &args->handle);
Signature · 1 line
1.8.5.3
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#3 lore raw

Re: [PATCH 2/7] drm/udl: fix Bpp calculation in dumb_create()

Hi

Quoted 9 lines · Daniel Vetter
Quoted 8 lines · David Herrmann

Probably a typo.. we obviously need "(bpp + 7) / 8" instead of "(bpp + 1) / 8". Unlikely to be hit in any sane code, but lets be safe.

---
 drivers/gpu/drm/udl/udl_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

drivers/gpu/drm/udl/udl_gem.c int udl_dumb_create(struct drm_file *file, · line 63

Quoted 10 lines
drivers/gpu/drm/udl/udl_gem.c +1 -1
index 8d67b94..df963a1 100644
@@ -60,7 +60,7 @@ int udl_dumb_create(struct drm_file *file,
                  struct drm_device *dev,
                  struct drm_mode_create_dumb *args)
 {
-     args->pitch = args->width * ((args->bpp + 1) / 8);
+     args->pitch = args->width * ((args->bpp + 7) / 8);

DIV_ROUND_UP?

Hm, udl doesn't use this anywhere, so I'd like to keep consistency. I guess I will replace all those occurrences by DIV_ROUND_UP() and meld it into this fix (except if someone wants two separate commits?).

Thanks
David

Quoted 11 lines
Quoted 6 lines
drivers/gpu/drm/udl/udl_gem.c +0 -1
      args->size = args->pitch * args->height;
      return udl_gem_create(file, dev,
                            args->size, &args->handle);
--

1.8.5.3

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

#4 lore raw

PATCH v2 2/6 drm/udl: fix Bpp calculation in dumb_create()

In reply to David Herrmann

Probably a typo.. we obviously need "(bpp + 7) / 8" instead of "(bpp + 1) / 8". Unlikely to be hit in any sane code, but lets be safe. Use DIV_ROUND_UP() to avoid the problem entirely and make the core more readable.

---
 drivers/gpu/drm/udl/udl_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_gem.c +1 -1
index 8d67b94..be4fcd0 100644
@@ -60,7 +60,7 @@ int udl_dumb_create(struct drm_file *file,
 		    struct drm_device *dev,
 		    struct drm_mode_create_dumb *args)
 {
-	args->pitch = args->width * ((args->bpp + 1) / 8);
+	args->pitch = args->width * DIV_ROUND_UP(args->bpp, 8);
 	args->size = args->pitch * args->height;
 	return udl_gem_create(file, dev,
 			      args->size, &args->handle);
Signature · 1 line
1.8.5.3
#5 lore raw

Re: [PATCH v2 2/6] drm/udl: fix Bpp calculation in dumb_create()

ping..

Quoted 27 lines · David Herrmann

Probably a typo.. we obviously need "(bpp + 7) / 8" instead of "(bpp + 1) / 8". Unlikely to be hit in any sane code, but lets be safe. Use DIV_ROUND_UP() to avoid the problem entirely and make the core more readable.

---
 drivers/gpu/drm/udl/udl_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_gem.c +1 -2
index 8d67b94..be4fcd0 100644
@@ -60,7 +60,7 @@ int udl_dumb_create(struct drm_file *file,
                    struct drm_device *dev,
                    struct drm_mode_create_dumb *args)
 {
-       args->pitch = args->width * ((args->bpp + 1) / 8);
+       args->pitch = args->width * DIV_ROUND_UP(args->bpp, 8);
        args->size = args->pitch * args->height;
        return udl_gem_create(file, dev,
                              args->size, &args->handle);
--

1.8.5.3

#6 lore raw

PATCH 3/7 drm/udl: import prime-fds with proper page-alignment

In reply to David Herrmann

Instead of rounding down to the next lower page-boundary, round up. dma-buf guarantees that we can map buffers in multiples of a page, so if an exporter does not page-align, do it ourselves.

This avoids issues if the exported buffer contains an unaligned size and we crop it. In this case, the buffer is too small for the UDL CRTC. So we round up to page-size now and avoid black borders. Worst case is we end up reading out some random kernel memory, but we can never fault as the whole page has the same access-rights. And in this case it's an issue of the buggy exporting driver, not the importing one.

---
 drivers/gpu/drm/udl/udl_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_gem.c +1 -1
index df963a1..1069e57 100644
@@ -227,7 +227,7 @@ static int udl_prime_create(struct drm_device *dev,
 	struct udl_gem_object *obj;
 	int npages;
 
-	npages = size / PAGE_SIZE;
+	npages = PAGE_ALIGN(size) >> PAGE_SHIFT;
 
 	*obj_p = NULL;
 	obj = udl_gem_alloc_object(dev, npages * PAGE_SIZE);
Signature · 1 line
1.8.5.3
#7 lore raw

Re: [PATCH 3/7] drm/udl: import prime-fds with proper page-alignment

Quoted 21 lines · David Herrmann

Instead of rounding down to the next lower page-boundary, round up. dma-buf guarantees that we can map buffers in multiples of a page, so if an exporter does not page-align, do it ourselves.

This avoids issues if the exported buffer contains an unaligned size and we crop it. In this case, the buffer is too small for the UDL CRTC. So we round up to page-size now and avoid black borders. Worst case is we end up reading out some random kernel memory, but we can never fault as the whole page has the same access-rights. And in this case it's an issue of the buggy exporting driver, not the importing one.

---
 drivers/gpu/drm/udl/udl_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_gem.c +0 -0
index df963a1..1069e57 100644

drivers/gpu/drm/udl/udl_gem.c static int udl_prime_create(struct drm_device *dev, · line 230

Quoted 5 lines
drivers/gpu/drm/udl/udl_gem.c +1 -1
@@ -227,7 +227,7 @@ static int udl_prime_create(struct drm_device *dev,
 	struct udl_gem_object *obj;
 	int npages;
 
-	npages = size / PAGE_SIZE;
+	npages = PAGE_ALIGN(size) >> PAGE_SHIFT;

Imo the proper patch would be to reject exporting anything which isn't page-aligned as a dma-buf in the driver core (together with a quick review of the docs to make sure this requirement is clear). This is just a bug in the exporter.
-Daniel

Quoted 6 lines
drivers/gpu/drm/udl/udl_gem.c +0 -0
 	*obj_p = NULL;
 	obj = udl_gem_alloc_object(dev, npages * PAGE_SIZE);
Signature · 1 line
1.8.5.3
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#8 lore raw

Re: [PATCH 3/7] drm/udl: import prime-fds with proper page-alignment

Hi

Quoted 25 lines · Daniel Vetter
Quoted 24 lines · David Herrmann

Instead of rounding down to the next lower page-boundary, round up. dma-buf guarantees that we can map buffers in multiples of a page, so if an exporter does not page-align, do it ourselves.

This avoids issues if the exported buffer contains an unaligned size and we crop it. In this case, the buffer is too small for the UDL CRTC. So we round up to page-size now and avoid black borders. Worst case is we end up reading out some random kernel memory, but we can never fault as the whole page has the same access-rights. And in this case it's an issue of the buggy exporting driver, not the importing one.

---
 drivers/gpu/drm/udl/udl_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_gem.c +0 -0
index df963a1..1069e57 100644
@@ -227,7 +227,7 @@ static int udl_prime_create(struct drm_device *dev,
      struct udl_gem_object *obj;
      int npages;
 
Quoted 7 lines

drivers/gpu/drm/udl/udl_gem.c static int udl_prime_create(struct drm_device *dev, · line 230

Quoted 2 lines
drivers/gpu/drm/udl/udl_gem.c +1 -1
-     npages = size / PAGE_SIZE;
+     npages = PAGE_ALIGN(size) >> PAGE_SHIFT;

Imo the proper patch would be to reject exporting anything which isn't page-aligned as a dma-buf in the driver core (together with a quick review of the docs to make sure this requirement is clear). This is just a bug in the exporter.

Ok, I've dropped this one for now. I think the best way to deal with it is to make dma_buf disallow any non-aligned sizes during initialization. So we should just assume it's always page-aligned.

Thanks
David

#9 lore raw

PATCH 4/7 drm/gem: fix indentation

In reply to David Herrmann

Remove double-whitespace and wrong indentation.

---
 drivers/gpu/drm/drm_gem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_gem.c +2 -2
index bed5c3b..c1eaf35 100644
@@ -691,7 +691,7 @@ drm_gem_object_release(struct drm_gem_object *obj)
 	WARN_ON(obj->dma_buf);
 
 	if (obj->filp)
-	    fput(obj->filp);
+		fput(obj->filp);
 }
 EXPORT_SYMBOL(drm_gem_object_release);
 
@@ -781,7 +781,7 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
 	vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP;
 	vma->vm_ops = dev->driver->gem_vm_ops;
 	vma->vm_private_data = obj;
-	vma->vm_page_prot =  pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
+	vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
 
 	/* Take a ref for this mapping of the object, so that the fault
 	 * handler can dereference the mmap offset's pointer to the object.
Signature · 1 line
1.8.5.3
#10 lore raw

Re: [PATCH 4/7] drm/gem: fix indentation

ping

Quoted 32 lines · David Herrmann

Remove double-whitespace and wrong indentation.

---
 drivers/gpu/drm/drm_gem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_gem.c +2 -3
index bed5c3b..c1eaf35 100644
@@ -691,7 +691,7 @@ drm_gem_object_release(struct drm_gem_object *obj)
        WARN_ON(obj->dma_buf);
 
        if (obj->filp)
-           fput(obj->filp);
+               fput(obj->filp);
 }
 EXPORT_SYMBOL(drm_gem_object_release);
 
@@ -781,7 +781,7 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
        vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP;
        vma->vm_ops = dev->driver->gem_vm_ops;
        vma->vm_private_data = obj;
-       vma->vm_page_prot =  pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
+       vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
 
        /* Take a ref for this mapping of the object, so that the fault
         * handler can dereference the mmap offset's pointer to the object.
--

1.8.5.3

#11 lore raw

PATCH 5/7 drm/gem: free vma-node during object-cleanup

In reply to David Herrmann

All drivers currently need to clean up the vma-node manually. There is no fancy logic involved so lets just clean it up unconditionally. The vma-manager correctly catches multiple calls so we are fine.

---
 drivers/gpu/drm/drm_gem.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_gem.c +2 -0
index c1eaf35..7bf374e 100644
@@ -692,6 +692,8 @@ drm_gem_object_release(struct drm_gem_object *obj)
 
 	if (obj->filp)
 		fput(obj->filp);
+
+	drm_gem_free_mmap_offset(obj);
 }
 EXPORT_SYMBOL(drm_gem_object_release);
 
Signature · 1 line
1.8.5.3
#12 lore raw

Re: [PATCH 5/7] drm/gem: free vma-node during object-cleanup

ping

Quoted 25 lines · David Herrmann

All drivers currently need to clean up the vma-node manually. There is no fancy logic involved so lets just clean it up unconditionally. The vma-manager correctly catches multiple calls so we are fine.

---
 drivers/gpu/drm/drm_gem.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/drm_gem.c +2 -1
index c1eaf35..7bf374e 100644
@@ -692,6 +692,8 @@ drm_gem_object_release(struct drm_gem_object *obj)
 
        if (obj->filp)
                fput(obj->filp);
+
+       drm_gem_free_mmap_offset(obj);
 }
 EXPORT_SYMBOL(drm_gem_object_release);
 
--

1.8.5.3

#13 lore raw

PATCH 6/7 drm/crtc: add sanity checks to create_dumb()

In reply to David Herrmann

Lets make sure some basic expressions are always true:
bpp != NULL
width != NULL
height != NULL
stride = bpp * width < 2^32
size = stride * height < 2^32 PAGE_ALIGN(size) < 2^32

At least the udl driver doesn't check for multiplication-overflows, so lets just make sure it will never happen. These checks allow drivers to do any 32bit math without having to test for mult-overflows themselves.

The two divisions might hurt performance a bit, but dumb_create() is only used for scanout-buffers, so that should be fine. We could use 64bit math to avoid the divisions, but that may be slow on 32bit machines.. Or maybe there should just be a "safe_mult32()" helper, which currently doesn't exist (I think?).

---
 drivers/gpu/drm/drm_crtc.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/gpu/drm/drm_crtc.c +15 -0
index 266a01d..ff647fa 100644
@@ -3738,9 +3738,24 @@ int drm_mode_create_dumb_ioctl(struct drm_device *dev,
 			       void *data, struct drm_file *file_priv)
 {
 	struct drm_mode_create_dumb *args = data;
+	u32 Bpp, stride, size;
 
 	if (!dev->driver->dumb_create)
 		return -ENOSYS;
+	if (!args->width || !args->height || !args->bpp)
+		return -EINVAL;
+
+	/* overflow checks for 32bit size calculations */
+	Bpp = (args->bpp + 7) / 8;
+	if (Bpp > 0xffffffffU / args->width)
+		return -EINVAL;
+	stride = Bpp * args->width;
+	if (args->height > 0xffffffffU / stride)
+		return -EINVAL;
+	size = args->height * stride;
+	if (PAGE_ALIGN(size) < size)
+		return -EINVAL;
+
 	return dev->driver->dumb_create(file_priv, dev, args);
 }
 
Signature · 1 line
1.8.5.3
#14 lore raw

Re: [PATCH 6/7] drm/crtc: add sanity checks to create_dumb()

Quoted 28 lines · David Herrmann

Lets make sure some basic expressions are always true:
bpp != NULL
width != NULL
height != NULL
stride = bpp * width < 2^32
size = stride * height < 2^32 PAGE_ALIGN(size) < 2^32

At least the udl driver doesn't check for multiplication-overflows, so lets just make sure it will never happen. These checks allow drivers to do any 32bit math without having to test for mult-overflows themselves.

The two divisions might hurt performance a bit, but dumb_create() is only used for scanout-buffers, so that should be fine. We could use 64bit math to avoid the divisions, but that may be slow on 32bit machines.. Or maybe there should just be a "safe_mult32()" helper, which currently doesn't exist (I think?).

---
 drivers/gpu/drm/drm_crtc.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/gpu/drm/drm_crtc.c +0 -0
index 266a01d..ff647fa 100644

drivers/gpu/drm/drm_crtc.c int drm_mode_create_dumb_ioctl(struct drm_device *dev, · line 3741

Quoted 4 lines
drivers/gpu/drm/drm_crtc.c +1 -0
@@ -3738,9 +3738,24 @@ int drm_mode_create_dumb_ioctl(struct drm_device *dev,
 			       void *data, struct drm_file *file_priv)
 {
 	struct drm_mode_create_dumb *args = data;
+	u32 Bpp, stride, size;

s/Bpp/bpp/

drivers/gpu/drm/drm_crtc.c int drm_mode_create_dumb_ioctl(struct drm_device *dev, · line 3749

Quoted 8 lines
drivers/gpu/drm/drm_crtc.c +5 -0
 	if (!dev->driver->dumb_create)
 		return -ENOSYS;
+	if (!args->width || !args->height || !args->bpp)
+		return -EINVAL;
+
+	/* overflow checks for 32bit size calculations */
+	Bpp = (args->bpp + 7) / 8;

Again DIV_ROUND_UP

drivers/gpu/drm/drm_crtc.c int drm_mode_create_dumb_ioctl(struct drm_device *dev, · line 3756

Quoted 7 lines
drivers/gpu/drm/drm_crtc.c +7 -0
+	if (Bpp > 0xffffffffU / args->width)
+		return -EINVAL;
+	stride = Bpp * args->width;
+	if (args->height > 0xffffffffU / stride)
+		return -EINVAL;
+	size = args->height * stride;
+	if (PAGE_ALIGN(size) < size)

Maybe check for 0 here and add a small comment that this checks wrap-around.
-Daniel

Quoted 8 lines
drivers/gpu/drm/drm_crtc.c +2 -0
+		return -EINVAL;
+
 	return dev->driver->dumb_create(file_priv, dev, args);
 }
 
Signature · 1 line
1.8.5.3
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#15 lore raw

Re: [PATCH 6/7] drm/crtc: add sanity checks to create_dumb()

Hi

Quoted 24 lines · Daniel Vetter
Quoted 23 lines · David Herrmann

Lets make sure some basic expressions are always true:
bpp != NULL
width != NULL
height != NULL
stride = bpp * width < 2^32
size = stride * height < 2^32 PAGE_ALIGN(size) < 2^32

At least the udl driver doesn't check for multiplication-overflows, so lets just make sure it will never happen. These checks allow drivers to do any 32bit math without having to test for mult-overflows themselves.

The two divisions might hurt performance a bit, but dumb_create() is only used for scanout-buffers, so that should be fine. We could use 64bit math to avoid the divisions, but that may be slow on 32bit machines.. Or maybe there should just be a "safe_mult32()" helper, which currently doesn't exist (I think?).

---
 drivers/gpu/drm/drm_crtc.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
Quoted 11 lines

drivers/gpu/drm/drm_crtc.c int drm_mode_create_dumb_ioctl(struct drm_device *dev, · line 3741

Quoted 9 lines
drivers/gpu/drm/drm_crtc.c +1 -0
index 266a01d..ff647fa 100644
@@ -3738,9 +3738,24 @@ int drm_mode_create_dumb_ioctl(struct drm_device *dev,
                             void *data, struct drm_file *file_priv)
 {
      struct drm_mode_create_dumb *args = data;
+     u32 Bpp, stride, size;

s/Bpp/bpp/

It's actually "Bytes per pixel", not "Bits per pixel". We generally use "bpp" as "bits per pixel" so I'd like to avoid the confusion. But yeah, upper-case names are unusual so I can also use bytes_pp or sth similar?

Quoted 10 lines

drivers/gpu/drm/drm_crtc.c int drm_mode_create_dumb_ioctl(struct drm_device *dev, · line 3749

Quoted 8 lines
drivers/gpu/drm/drm_crtc.c +5 -0
      if (!dev->driver->dumb_create)
              return -ENOSYS;
+     if (!args->width || !args->height || !args->bpp)
+             return -EINVAL;
+
+     /* overflow checks for 32bit size calculations */
+     Bpp = (args->bpp + 7) / 8;

Again DIV_ROUND_UP

yepp, fixed.

Quoted 11 lines

drivers/gpu/drm/drm_crtc.c int drm_mode_create_dumb_ioctl(struct drm_device *dev, · line 3756

Quoted 8 lines
drivers/gpu/drm/drm_crtc.c +7 -0
+     if (Bpp > 0xffffffffU / args->width)
+             return -EINVAL;
+     stride = Bpp * args->width;
+     if (args->height > 0xffffffffU / stride)
+             return -EINVAL;
+     size = args->height * stride;
+     if (PAGE_ALIGN(size) < size)

Maybe check for 0 here and add a small comment that this checks wrap-around.

Hm, the comment above those if()s already says "overflow checks", and it should be obvious that all three are overflow checks, so I don't think we need another comment (especially because I didn't add any empty lines between them).

I will change it to "if (!PAGE_ALIGN(size))". The "x + off < x" is an addition-overflow-check so I think it doesn't apply here.

Thanks
David

Quoted 14 lines
Quoted 9 lines
drivers/gpu/drm/drm_crtc.c +2 -1
+             return -EINVAL;
+
      return dev->driver->dumb_create(file_priv, dev, args);
 }
 
--

1.8.5.3

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

#16 lore raw

Re: [PATCH 6/7] drm/crtc: add sanity checks to create_dumb()

Quoted 39 lines · David Herrmann

Hi

Quoted 24 lines · Daniel Vetter
Quoted 23 lines · David Herrmann

Lets make sure some basic expressions are always true:
bpp != NULL
width != NULL
height != NULL
stride = bpp * width < 2^32
size = stride * height < 2^32 PAGE_ALIGN(size) < 2^32

At least the udl driver doesn't check for multiplication-overflows, so lets just make sure it will never happen. These checks allow drivers to do any 32bit math without having to test for mult-overflows themselves.

The two divisions might hurt performance a bit, but dumb_create() is only used for scanout-buffers, so that should be fine. We could use 64bit math to avoid the divisions, but that may be slow on 32bit machines.. Or maybe there should just be a "safe_mult32()" helper, which currently doesn't exist (I think?).

---
 drivers/gpu/drm/drm_crtc.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
Quoted 11 lines

drivers/gpu/drm/drm_crtc.c int drm_mode_create_dumb_ioctl(struct drm_device *dev, · line 3741

Quoted 9 lines
drivers/gpu/drm/drm_crtc.c +1 -0
index 266a01d..ff647fa 100644
@@ -3738,9 +3738,24 @@ int drm_mode_create_dumb_ioctl(struct drm_device *dev,
                             void *data, struct drm_file *file_priv)
 {
      struct drm_mode_create_dumb *args = data;
+     u32 Bpp, stride, size;

s/Bpp/bpp/

Quoted 4 lines

It's actually "Bytes per pixel", not "Bits per pixel". We generally use "bpp" as "bits per pixel" so I'd like to avoid the confusion. But yeah, upper-case names are unusual so I can also use bytes_pp or sth similar?

cpp is fairly commonly used for bytes per pixel, if you want to stick to something short but still recognizable.

Quoted 55 lines
Quoted 11 lines

drivers/gpu/drm/drm_crtc.c int drm_mode_create_dumb_ioctl(struct drm_device *dev, · line 3749

Quoted 9 lines
drivers/gpu/drm/drm_crtc.c +5 -0
      if (!dev->driver->dumb_create)
              return -ENOSYS;
+     if (!args->width || !args->height || !args->bpp)
+             return -EINVAL;
+
+     /* overflow checks for 32bit size calculations */
+     Bpp = (args->bpp + 7) / 8;

Again DIV_ROUND_UP

yepp, fixed.

Quoted 11 lines

drivers/gpu/drm/drm_crtc.c int drm_mode_create_dumb_ioctl(struct drm_device *dev, · line 3756

Quoted 8 lines
drivers/gpu/drm/drm_crtc.c +7 -0
+     if (Bpp > 0xffffffffU / args->width)
+             return -EINVAL;
+     stride = Bpp * args->width;
+     if (args->height > 0xffffffffU / stride)
+             return -EINVAL;
+     size = args->height * stride;
+     if (PAGE_ALIGN(size) < size)

Maybe check for 0 here and add a small comment that this checks wrap-around.

Hm, the comment above those if()s already says "overflow checks", and it should be obvious that all three are overflow checks, so I don't think we need another comment (especially because I didn't add any empty lines between them).

I will change it to "if (!PAGE_ALIGN(size))". The "x + off < x" is an addition-overflow-check so I think it doesn't apply here.

Thanks
David

Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/drm_crtc.c +2 -0
+             return -EINVAL;
+
      return dev->driver->dumb_create(file_priv, dev, args);
 }
 
Quoted 8 lines
Quoted 3 lines
drivers/gpu/drm/drm_crtc.c +0 -1
--

1.8.5.3

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 2 lines
Ville Syrjälä
Intel OTC
#17 lore raw

Re: [PATCH 6/7] drm/crtc: add sanity checks to create_dumb()

Hi

Quoted 40 lines · Ville Syrjälä
Quoted 39 lines · David Herrmann

Hi

Quoted 35 lines · Daniel Vetter
Quoted 28 lines · David Herrmann

Lets make sure some basic expressions are always true:
bpp != NULL
width != NULL
height != NULL
stride = bpp * width < 2^32
size = stride * height < 2^32 PAGE_ALIGN(size) < 2^32

At least the udl driver doesn't check for multiplication-overflows, so lets just make sure it will never happen. These checks allow drivers to do any 32bit math without having to test for mult-overflows themselves.

The two divisions might hurt performance a bit, but dumb_create() is only used for scanout-buffers, so that should be fine. We could use 64bit math to avoid the divisions, but that may be slow on 32bit machines.. Or maybe there should just be a "safe_mult32()" helper, which currently doesn't exist (I think?).

---
 drivers/gpu/drm/drm_crtc.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/gpu/drm/drm_crtc.c +0 -0
index 266a01d..ff647fa 100644

drivers/gpu/drm/drm_crtc.c int drm_mode_create_dumb_ioctl(struct drm_device *dev, · line 3741

Quoted 4 lines
drivers/gpu/drm/drm_crtc.c +1 -0
@@ -3738,9 +3738,24 @@ int drm_mode_create_dumb_ioctl(struct drm_device *dev,
                             void *data, struct drm_file *file_priv)
 {
      struct drm_mode_create_dumb *args = data;
+     u32 Bpp, stride, size;

s/Bpp/bpp/

Quoted 7 lines
Quoted 4 lines

It's actually "Bytes per pixel", not "Bits per pixel". We generally use "bpp" as "bits per pixel" so I'd like to avoid the confusion. But yeah, upper-case names are unusual so I can also use bytes_pp or sth similar?

cpp is fairly commonly used for bytes per pixel, if you want to stick to something short but still recognizable.

Because "c" comes after "b"? Or is there any other logic here? But sounds good, will send a v2 shortly.

Thanks
David

#18 lore raw

Re: [PATCH 6/7] drm/crtc: add sanity checks to create_dumb()

Quoted 49 lines · David Herrmann

Hi

Quoted 45 lines · Ville Syrjälä
Quoted 43 lines · David Herrmann

Hi

Quoted 24 lines · Daniel Vetter
Quoted 23 lines · David Herrmann

Lets make sure some basic expressions are always true:
bpp != NULL
width != NULL
height != NULL
stride = bpp * width < 2^32
size = stride * height < 2^32 PAGE_ALIGN(size) < 2^32

At least the udl driver doesn't check for multiplication-overflows, so lets just make sure it will never happen. These checks allow drivers to do any 32bit math without having to test for mult-overflows themselves.

The two divisions might hurt performance a bit, but dumb_create() is only used for scanout-buffers, so that should be fine. We could use 64bit math to avoid the divisions, but that may be slow on 32bit machines.. Or maybe there should just be a "safe_mult32()" helper, which currently doesn't exist (I think?).

---
 drivers/gpu/drm/drm_crtc.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
Quoted 11 lines

drivers/gpu/drm/drm_crtc.c int drm_mode_create_dumb_ioctl(struct drm_device *dev, · line 3741

Quoted 9 lines
drivers/gpu/drm/drm_crtc.c +1 -0
index 266a01d..ff647fa 100644
@@ -3738,9 +3738,24 @@ int drm_mode_create_dumb_ioctl(struct drm_device *dev,
                             void *data, struct drm_file *file_priv)
 {
      struct drm_mode_create_dumb *args = data;
+     u32 Bpp, stride, size;

s/Bpp/bpp/

It's actually "Bytes per pixel", not "Bits per pixel". We generally use "bpp" as "bits per pixel" so I'd like to avoid the confusion. But yeah, upper-case names are unusual so I can also use bytes_pp or sth similar?

Quoted 5 lines
Quoted 2 lines

cpp is fairly commonly used for bytes per pixel, if you want to stick to something short but still recognizable.

Because "c" comes after "b"? Or is there any other logic here? But sounds good, will send a v2 shortly.

chars (octets) per pixel.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#19 lore raw

PATCH v2 5/6 drm/crtc: add sanity checks to create_dumb()

In reply to David Herrmann

Lets make sure some basic expressions are always true:
bpp != NULL
width != NULL
height != NULL
stride = bpp * width < 2^32
size = stride * height < 2^32 PAGE_ALIGN(size) < 2^32

At least the udl driver doesn't check for multiplication-overflows, so lets just make sure it will never happen. These checks allow drivers to do any 32bit math without having to test for mult-overflows themselves.

The two divisions might hurt performance a bit, but dumb_create() is only used for scanout-buffers, so that should be fine. We could use 64bit math to avoid the divisions, but that may be slow on 32bit machines.. Or maybe there should just be a "safe_mult32()" helper, which currently doesn't exist (I think?).

---
 drivers/gpu/drm/drm_crtc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/gpu/drm/drm_crtc.c +17 -0
index 266a01d..2b50702 100644
@@ -3738,9 +3738,26 @@ int drm_mode_create_dumb_ioctl(struct drm_device *dev,
 			       void *data, struct drm_file *file_priv)
 {
 	struct drm_mode_create_dumb *args = data;
+	u32 cpp, stride, size;
 
 	if (!dev->driver->dumb_create)
 		return -ENOSYS;
+	if (!args->width || !args->height || !args->bpp)
+		return -EINVAL;
+
+	/* overflow checks for 32bit size calculations */
+	cpp = DIV_ROUND_UP(args->bpp, 8);
+	if (cpp > 0xffffffffU / args->width)
+		return -EINVAL;
+	stride = cpp * args->width;
+	if (args->height > 0xffffffffU / stride)
+		return -EINVAL;
+
+	/* test for wrap-around */
+	size = args->height * stride;
+	if (PAGE_ALIGN(size) == 0)
+		return -EINVAL;
+
 	return dev->driver->dumb_create(file_priv, dev, args);
 }
 
Signature · 1 line
1.8.5.3
#20 lore raw

Re: [PATCH v2 5/6] drm/crtc: add sanity checks to create_dumb()

Quoted 33 lines · David Herrmann

Lets make sure some basic expressions are always true:
bpp != NULL
width != NULL
height != NULL
stride = bpp * width < 2^32
size = stride * height < 2^32 PAGE_ALIGN(size) < 2^32

At least the udl driver doesn't check for multiplication-overflows, so lets just make sure it will never happen. These checks allow drivers to do any 32bit math without having to test for mult-overflows themselves.

The two divisions might hurt performance a bit, but dumb_create() is only used for scanout-buffers, so that should be fine. We could use 64bit math to avoid the divisions, but that may be slow on 32bit machines.. Or maybe there should just be a "safe_mult32()" helper, which currently doesn't exist (I think?).

---
 drivers/gpu/drm/drm_crtc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/gpu/drm/drm_crtc.c +1 -0
index 266a01d..2b50702 100644
@@ -3738,9 +3738,26 @@ int drm_mode_create_dumb_ioctl(struct drm_device *dev,
 			       void *data, struct drm_file *file_priv)
 {
 	struct drm_mode_create_dumb *args = data;
+	u32 cpp, stride, size;

drivers/gpu/drm/drm_crtc.c int drm_mode_create_dumb_ioctl(struct drm_device *dev, · line 3751

Quoted 10 lines
drivers/gpu/drm/drm_crtc.c +7 -0
 
 	if (!dev->driver->dumb_create)
 		return -ENOSYS;
+	if (!args->width || !args->height || !args->bpp)
+		return -EINVAL;
+
+	/* overflow checks for 32bit size calculations */
+	cpp = DIV_ROUND_UP(args->bpp, 8);
+	if (cpp > 0xffffffffU / args->width)
+		return -EINVAL;

IIRC I used -ERANGE for such things in some drm_framebuffer checks. Not sure if that's the best error value or not, but using the same one in both places would be nice.

Quoted 19 lines
drivers/gpu/drm/drm_crtc.c +9 -0
+	stride = cpp * args->width;
+	if (args->height > 0xffffffffU / stride)
+		return -EINVAL;
+
+	/* test for wrap-around */
+	size = args->height * stride;
+	if (PAGE_ALIGN(size) == 0)
+		return -EINVAL;
+
 	return dev->driver->dumb_create(file_priv, dev, args);
 }
 
Signature · 6 lines
1.8.5.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 2 lines
Ville Syrjälä
Intel OTC
#21 lore raw

Re: [PATCH v2 5/6] drm/crtc: add sanity checks to create_dumb()

Hi

Quoted 35 lines · Ville Syrjälä
Quoted 34 lines · David Herrmann

Lets make sure some basic expressions are always true:
bpp != NULL
width != NULL
height != NULL
stride = bpp * width < 2^32
size = stride * height < 2^32 PAGE_ALIGN(size) < 2^32

At least the udl driver doesn't check for multiplication-overflows, so lets just make sure it will never happen. These checks allow drivers to do any 32bit math without having to test for mult-overflows themselves.

The two divisions might hurt performance a bit, but dumb_create() is only used for scanout-buffers, so that should be fine. We could use 64bit math to avoid the divisions, but that may be slow on 32bit machines.. Or maybe there should just be a "safe_mult32()" helper, which currently doesn't exist (I think?).

---
 drivers/gpu/drm/drm_crtc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/gpu/drm/drm_crtc.c +1 -0
index 266a01d..2b50702 100644
@@ -3738,9 +3738,26 @@ int drm_mode_create_dumb_ioctl(struct drm_device *dev,
                             void *data, struct drm_file *file_priv)
 {
      struct drm_mode_create_dumb *args = data;
+     u32 cpp, stride, size;
 
Quoted 13 lines

drivers/gpu/drm/drm_crtc.c int drm_mode_create_dumb_ioctl(struct drm_device *dev, · line 3751

Quoted 9 lines
drivers/gpu/drm/drm_crtc.c +7 -0
      if (!dev->driver->dumb_create)
              return -ENOSYS;
+     if (!args->width || !args->height || !args->bpp)
+             return -EINVAL;
+
+     /* overflow checks for 32bit size calculations */
+     cpp = DIV_ROUND_UP(args->bpp, 8);
+     if (cpp > 0xffffffffU / args->width)
+             return -EINVAL;

IIRC I used -ERANGE for such things in some drm_framebuffer checks. Not sure if that's the best error value or not, but using the same one in both places would be nice.

I'm actually a fan of EINVAL here, as this is really more about "do the arguments make sense?" than "does the range exceed the driver's capabilities?" But what do I know.. So more comments on that are welcome. And btw., we already mix EINVAL and ERANGE so this would just contribute to the already existing mess (see the stride verifications which usually return EINVAL, but the overflow checks often return ERANGE).

Thanks
David

Quoted 23 lines
Quoted 15 lines
drivers/gpu/drm/drm_crtc.c +9 -1
+     stride = cpp * args->width;
+     if (args->height > 0xffffffffU / stride)
+             return -EINVAL;
+
+     /* test for wrap-around */
+     size = args->height * stride;
+     if (PAGE_ALIGN(size) == 0)
+             return -EINVAL;
+
      return dev->driver->dumb_create(file_priv, dev, args);
 }
 
--

1.8.5.3

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Ville Syrjälä
Intel OTC

#22 lore raw

Re: [PATCH v2 5/6] drm/crtc: add sanity checks to create_dumb()

ping

Quoted 87 lines · David Herrmann

Hi

Quoted 35 lines · Ville Syrjälä
Quoted 34 lines · David Herrmann

Lets make sure some basic expressions are always true:
bpp != NULL
width != NULL
height != NULL
stride = bpp * width < 2^32
size = stride * height < 2^32 PAGE_ALIGN(size) < 2^32

At least the udl driver doesn't check for multiplication-overflows, so lets just make sure it will never happen. These checks allow drivers to do any 32bit math without having to test for mult-overflows themselves.

The two divisions might hurt performance a bit, but dumb_create() is only used for scanout-buffers, so that should be fine. We could use 64bit math to avoid the divisions, but that may be slow on 32bit machines.. Or maybe there should just be a "safe_mult32()" helper, which currently doesn't exist (I think?).

---
 drivers/gpu/drm/drm_crtc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/gpu/drm/drm_crtc.c +1 -0
index 266a01d..2b50702 100644
@@ -3738,9 +3738,26 @@ int drm_mode_create_dumb_ioctl(struct drm_device *dev,
                             void *data, struct drm_file *file_priv)
 {
      struct drm_mode_create_dumb *args = data;
+     u32 cpp, stride, size;
 
Quoted 13 lines

drivers/gpu/drm/drm_crtc.c int drm_mode_create_dumb_ioctl(struct drm_device *dev, · line 3751

Quoted 9 lines
drivers/gpu/drm/drm_crtc.c +7 -0
      if (!dev->driver->dumb_create)
              return -ENOSYS;
+     if (!args->width || !args->height || !args->bpp)
+             return -EINVAL;
+
+     /* overflow checks for 32bit size calculations */
+     cpp = DIV_ROUND_UP(args->bpp, 8);
+     if (cpp > 0xffffffffU / args->width)
+             return -EINVAL;

IIRC I used -ERANGE for such things in some drm_framebuffer checks. Not sure if that's the best error value or not, but using the same one in both places would be nice.

I'm actually a fan of EINVAL here, as this is really more about "do the arguments make sense?" than "does the range exceed the driver's capabilities?" But what do I know.. So more comments on that are welcome. And btw., we already mix EINVAL and ERANGE so this would just contribute to the already existing mess (see the stride verifications which usually return EINVAL, but the overflow checks often return ERANGE).

Thanks
David

Quoted 23 lines
Quoted 15 lines
drivers/gpu/drm/drm_crtc.c +9 -1
+     stride = cpp * args->width;
+     if (args->height > 0xffffffffU / stride)
+             return -EINVAL;
+
+     /* test for wrap-around */
+     size = args->height * stride;
+     if (PAGE_ALIGN(size) == 0)
+             return -EINVAL;
+
      return dev->driver->dumb_create(file_priv, dev, args);
 }
 
--

1.8.5.3

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Ville Syrjälä
Intel OTC

#23 lore raw

PATCH 7/7 drm/gem: dont init "ret" in drm_gem_mmap()

In reply to David Herrmann

There is no need to initialize this variable, so drop it. Otherwise, the compiler won't warn if we use it unintialized.

---
 drivers/gpu/drm/drm_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_gem.c +1 -1
index 7bf374e..700e8df 100644
@@ -819,7 +819,7 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 	struct drm_device *dev = priv->minor->dev;
 	struct drm_gem_object *obj;
 	struct drm_vma_offset_node *node;
-	int ret = 0;
+	int ret;
 
 	if (drm_device_is_unplugged(dev))
 		return -ENODEV;
Signature · 1 line
1.8.5.3
Reviewed-by on v1 7/7
#24 lore raw

Re: [PATCH 7/7] drm/gem: dont init "ret" in drm_gem_mmap()

Quoted 4 lines · David Herrmann

There is no need to initialize this variable, so drop it. Otherwise, the compiler won't warn if we use it unintialized.

I've replied with a few small comments on some patches, with those addressed all but patch 3 are

A follow-up to 4 to remove callsites from drivers would be neat though. -Daniel

Quoted 20 lines
---
 drivers/gpu/drm/drm_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_gem.c +1 -1
index 7bf374e..700e8df 100644
@@ -819,7 +819,7 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 	struct drm_device *dev = priv->minor->dev;
 	struct drm_gem_object *obj;
 	struct drm_vma_offset_node *node;
-	int ret = 0;
+	int ret;
 
 	if (drm_device_is_unplugged(dev))
 		return -ENODEV;
Signature · 1 line
1.8.5.3
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#25 lore raw

Re: [PATCH 7/7] drm/gem: dont init "ret" in drm_gem_mmap()

ping

Quoted 39 lines · Daniel Vetter
Quoted 4 lines · David Herrmann

There is no need to initialize this variable, so drop it. Otherwise, the compiler won't warn if we use it unintialized.

I've replied with a few small comments on some patches, with those addressed all but patch 3 are

A follow-up to 4 to remove callsites from drivers would be neat though. -Daniel

Quoted 18 lines
---
 drivers/gpu/drm/drm_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_gem.c +1 -2
index 7bf374e..700e8df 100644
@@ -819,7 +819,7 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
      struct drm_device *dev = priv->minor->dev;
      struct drm_gem_object *obj;
      struct drm_vma_offset_node *node;
-     int ret = 0;
+     int ret;
 
      if (drm_device_is_unplugged(dev))
              return -ENODEV;
--
Quoted 2 lines

1.8.5.3

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

#26 lore raw
In reply to David Herrmann
Quoted 13 lines · David Herrmann

We need to call dma_buf_end_cpu_access() in case a damage-request. Unlikely, but might happen during device unplug.

---
 drivers/gpu/drm/udl/udl_fb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_fb.c +0 -0
index dbadd49..50f564d 100644

drivers/gpu/drm/udl/udl_fb.c static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb, · line 424

Quoted 5 lines
drivers/gpu/drm/udl/udl_fb.c +1 -1
@@ -421,9 +421,10 @@ static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb,
 				  clips[i].x2 - clips[i].x1,
 				  clips[i].y2 - clips[i].y1);
 		if (ret)
-			goto unlock;
+			goto end_access;

break instead of a goto?

Quoted 9 lines
drivers/gpu/drm/udl/udl_fb.c +1 -0
 	}
 
+end_access:
 	if (ufb->obj->base.import_attach) {
 		dma_buf_end_cpu_access(ufb->obj->base.import_attach->dmabuf,
 				       0, ufb->obj->base.size,
Signature · 1 line
1.8.5.3
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#27 lore raw

PATCH v2 1/6 drm/udl: fix error-path when damage-req fails

In reply to David Herrmann

We need to call dma_buf_end_cpu_access() in case a damage-request. Unlikely, but might happen during device unplug.

---
 drivers/gpu/drm/udl/udl_fb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_fb.c +1 -1
index dbadd49..3771763 100644
@@ -421,7 +421,7 @@ static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb,
 				  clips[i].x2 - clips[i].x1,
 				  clips[i].y2 - clips[i].y1);
 		if (ret)
-			goto unlock;
+			break;
 	}
 
 	if (ufb->obj->base.import_attach) {
Signature · 1 line
1.8.5.3
#28 lore raw

ping..

Quoted 25 lines · David Herrmann

We need to call dma_buf_end_cpu_access() in case a damage-request. Unlikely, but might happen during device unplug.

---
 drivers/gpu/drm/udl/udl_fb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_fb.c +1 -2
index dbadd49..3771763 100644
@@ -421,7 +421,7 @@ static int udl_user_framebuffer_dirty(struct drm_framebuffer *fb,
                                  clips[i].x2 - clips[i].x1,
                                  clips[i].y2 - clips[i].y1);
                if (ret)
-                       goto unlock;
+                       break;
        }
 
        if (ufb->obj->base.import_attach) {
--

1.8.5.3