Skip to content

Commit

Permalink
video/fb: Propagate error code from failing to unregister conflicting fb
Browse files Browse the repository at this point in the history
If we fail to remove a conflicting fb driver, we need to abort the
loading of the second driver to avoid likely kernel panics.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: linux-fbdev@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
  • Loading branch information
Chris Wilson authored and Dave Airlie committed Dec 18, 2013
1 parent 73e9efd commit 46eeb2c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
31 changes: 21 additions & 10 deletions drivers/video/fbmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1577,10 +1577,10 @@ static bool fb_do_apertures_overlap(struct apertures_struct *gena,
static int do_unregister_framebuffer(struct fb_info *fb_info);

#define VGA_FB_PHYS 0xA0000
static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
const char *name, bool primary)
static int do_remove_conflicting_framebuffers(struct apertures_struct *a,
const char *name, bool primary)
{
int i;
int i, ret;

/* check all firmware fbs and kick off if the base addr overlaps */
for (i = 0 ; i < FB_MAX; i++) {
Expand All @@ -1599,22 +1599,29 @@ static void do_remove_conflicting_framebuffers(struct apertures_struct *a,
printk(KERN_INFO "fb: conflicting fb hw usage "
"%s vs %s - removing generic driver\n",
name, registered_fb[i]->fix.id);
do_unregister_framebuffer(registered_fb[i]);
ret = do_unregister_framebuffer(registered_fb[i]);
if (ret)
return ret;
}
}

return 0;
}

static int do_register_framebuffer(struct fb_info *fb_info)
{
int i;
int i, ret;
struct fb_event event;
struct fb_videomode mode;

if (fb_check_foreignness(fb_info))
return -ENOSYS;

do_remove_conflicting_framebuffers(fb_info->apertures, fb_info->fix.id,
fb_is_primary_device(fb_info));
ret = do_remove_conflicting_framebuffers(fb_info->apertures,
fb_info->fix.id,
fb_is_primary_device(fb_info));
if (ret)
return ret;

if (num_registered_fb == FB_MAX)
return -ENXIO;
Expand Down Expand Up @@ -1739,12 +1746,16 @@ int unlink_framebuffer(struct fb_info *fb_info)
}
EXPORT_SYMBOL(unlink_framebuffer);

void remove_conflicting_framebuffers(struct apertures_struct *a,
const char *name, bool primary)
int remove_conflicting_framebuffers(struct apertures_struct *a,
const char *name, bool primary)
{
int ret;

mutex_lock(&registration_lock);
do_remove_conflicting_framebuffers(a, name, primary);
ret = do_remove_conflicting_framebuffers(a, name, primary);
mutex_unlock(&registration_lock);

return ret;
}
EXPORT_SYMBOL(remove_conflicting_framebuffers);

Expand Down
4 changes: 2 additions & 2 deletions include/linux/fb.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,8 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
extern int register_framebuffer(struct fb_info *fb_info);
extern int unregister_framebuffer(struct fb_info *fb_info);
extern int unlink_framebuffer(struct fb_info *fb_info);
extern void remove_conflicting_framebuffers(struct apertures_struct *a,
const char *name, bool primary);
extern int remove_conflicting_framebuffers(struct apertures_struct *a,
const char *name, bool primary);
extern int fb_prepare_logo(struct fb_info *fb_info, int rotate);
extern int fb_show_logo(struct fb_info *fb_info, int rotate);
extern char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size);
Expand Down

0 comments on commit 46eeb2c

Please sign in to comment.