Skip to contentSkip to conversation

omap: Initialize DMA BUF file descriptor to -1

PATCH In review Thierry Reding 2 participants 2 messages Aug 26, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 omap: Initialize DMA BUF file descriptor to -1

From: Thierry Reding <[email protected]>

Commit c86dabfc9f04 ("omap: zero is a valid fd number, treat it as such") corrected checks for valid file descriptors, but the OMAP buffer object code initializes the DMA-BUF file descriptor to 0 (as a result of calloc()'ing the structure). Obviously this isn't going to work because subsequent code will try to use file descriptor 0 (most likely stdin at that point) as a DMA-BUF. It may also try and close stdin when a buffer object is destroyed.

Fix this by initializing the DMA-BUF file descriptor to -1, properly marking it as an invalid file descriptor.

Fixes c86dabfc9f04 ("omap: zero is a valid fd number, treat it as such")

---
Emil, I think this may warrant cutting a new release to unbreak OMAP. I can push the patch myself, but I've never done a libdrm release before, so maybe you want to do the honors?

 omap/omap_drm.c | 1 +
 1 file changed, 1 insertion(+)
omap/omap_drm.c +1 -0
index 4a0248d5e0d8..08ba64eb694d 100644
@@ -186,6 +186,7 @@ static struct omap_bo * bo_from_handle(struct omap_device *dev,
 	}
 	bo->dev = omap_device_ref(dev);
 	bo->handle = handle;
+	bo->fd = -1;
 	atomic_set(&bo->refcnt, 1);
 	/* add ourselves to the handle table: */
 	drmHashInsert(dev->handle_table, handle, bo);
Signature · 6 lines
2.4.5

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Thierry Reding

From: Thierry Reding <[email protected]>

Commit c86dabfc9f04 ("omap: zero is a valid fd number, treat it as such") corrected checks for valid file descriptors, but the OMAP buffer object code initializes the DMA-BUF file descriptor to 0 (as a result of calloc()'ing the structure). Obviously this isn't going to work because subsequent code will try to use file descriptor 0 (most likely stdin at that point) as a DMA-BUF. It may also try and close stdin when a buffer object is destroyed.

Quoted 3 lines

Fix this by initializing the DMA-BUF file descriptor to -1, properly marking it as an invalid file descriptor.

Sorry about this guys. I should have gone to specsavers ...

Quoted 4 lines
Fixes c86dabfc9f04 ("omap: zero is a valid fd number, treat it as such")
Quoted 5 lines

---
Emil, I think this may warrant cutting a new release to unbreak OMAP. I can push the patch myself, but I've never done a libdrm release before, so maybe you want to do the honors?

I would have done it in a second if it wasn't for the lack of feedback wrt the drmGetDevices API. I've been nudging people to take a look, perhaps you can do so too :-)

Alternatively I'll cut a new release in a couple of days.

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