[PATCH] drm/omap: Checking the mapping returned by vmap()

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

 



Because vmap() function could fail.
Also don't let omap_gem_vaddr() function signature (declaration) dangling
there, as it will only get defined when CONFIG_DRM_FBDEV_EMULATION=y.

Signed-off-by: Sui Jingfeng <suijingfeng@xxxxxxxxxxx>
---
 drivers/gpu/drm/omapdrm/omap_fbdev.c | 10 ++++++++--
 drivers/gpu/drm/omapdrm/omap_gem.h   |  3 +++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c
index b7ccce0704a3..2c88aa1008d8 100644
--- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
+++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
@@ -197,6 +197,11 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
 	drm_fb_helper_fill_info(fbi, helper, sizes);
 
 	fbi->screen_buffer = omap_gem_vaddr(bo);
+	if (!fbi->screen_buffer) {
+		ret = -ENOMEM;
+		goto err_release_fbi;
+	}
+
 	fbi->screen_size = bo->size;
 	fbi->fix.smem_start = dma_addr;
 	fbi->fix.smem_len = bo->size;
@@ -210,14 +215,15 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
 		fbi->fix.ywrapstep = 1;
 	}
 
-
 	DBG("par=%p, %dx%d", fbi->par, fbi->var.xres, fbi->var.yres);
 	DBG("allocated %dx%d fb", fb->width, fb->height);
 
 	return 0;
 
-fail:
+err_release_fbi:
+	drm_fb_helper_release_info(helper);
 
+fail:
 	if (ret) {
 		if (fb)
 			drm_framebuffer_remove(fb);
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.h b/drivers/gpu/drm/omapdrm/omap_gem.h
index 4d4488939f6b..7e8c41b72aae 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.h
+++ b/drivers/gpu/drm/omapdrm/omap_gem.h
@@ -48,7 +48,10 @@ struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
 		struct sg_table *sgt);
 int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
 		union omap_gem_size gsize, u32 flags, u32 *handle);
+
+#ifdef CONFIG_DRM_FBDEV_EMULATION
 void *omap_gem_vaddr(struct drm_gem_object *obj);
+#endif
 
 /* Dumb Buffers Interface */
 int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-- 
2.25.1




[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