Commit b13b8402 authored by Namrta Salonie's avatar Namrta Salonie Committed by Daniel Vetter

drm/i915: Fix possible null dereference in framebuffer_info debugfs function

Found by static code analysis tool.

v2: Inserted block instead of goto & renamed variables (Chris)
v3: Aligned code as per the opening brace (Chris)
    Rebased on top of nightly (Daniel)
Signed-off-by: default avatarNamrta Salonie <namrta.salonie@intel.com>
Signed-off-by: default avatarDeepak S <deepak.s@intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 81fd874e
...@@ -1869,33 +1869,29 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data) ...@@ -1869,33 +1869,29 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
{ {
struct drm_info_node *node = m->private; struct drm_info_node *node = m->private;
struct drm_device *dev = node->minor->dev; struct drm_device *dev = node->minor->dev;
struct intel_fbdev *ifbdev = NULL; struct intel_framebuffer *fbdev_fb = NULL;
struct intel_framebuffer *fb;
struct drm_framebuffer *drm_fb; struct drm_framebuffer *drm_fb;
#ifdef CONFIG_DRM_FBDEV_EMULATION #ifdef CONFIG_DRM_FBDEV_EMULATION
struct drm_i915_private *dev_priv = dev->dev_private; if (to_i915(dev)->fbdev) {
fbdev_fb = to_intel_framebuffer(to_i915(dev)->fbdev->helper.fb);
ifbdev = dev_priv->fbdev;
if (ifbdev) { seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ",
fb = to_intel_framebuffer(ifbdev->helper.fb); fbdev_fb->base.width,
fbdev_fb->base.height,
seq_printf(m, "fbcon size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", fbdev_fb->base.depth,
fb->base.width, fbdev_fb->base.bits_per_pixel,
fb->base.height, fbdev_fb->base.modifier[0],
fb->base.depth, atomic_read(&fbdev_fb->base.refcount.refcount));
fb->base.bits_per_pixel, describe_obj(m, fbdev_fb->obj);
fb->base.modifier[0], seq_putc(m, '\n');
atomic_read(&fb->base.refcount.refcount)); }
describe_obj(m, fb->obj);
seq_putc(m, '\n');
}
#endif #endif
mutex_lock(&dev->mode_config.fb_lock); mutex_lock(&dev->mode_config.fb_lock);
drm_for_each_fb(drm_fb, dev) { drm_for_each_fb(drm_fb, dev) {
fb = to_intel_framebuffer(drm_fb); struct intel_framebuffer *fb = to_intel_framebuffer(drm_fb);
if (ifbdev && &fb->base == ifbdev->helper.fb) if (fb == fbdev_fb)
continue; continue;
seq_printf(m, "user size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ", seq_printf(m, "user size: %d x %d, depth %d, %d bpp, modifier 0x%llx, refcount %d, obj ",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment