Commit 728f8660 authored by Archit Taneja's avatar Archit Taneja Committed by Dave Airlie

drm/mgag200: Fix driver_load error handling

mgag200_driver_load's error path just calls the drm driver's
driver_unload op. It isn't safe to call this because it doesn't handle
things well if driver_load fails somewhere mid way.

Replace the call to mgag200_driver_unload with a more finegrained
error handling path.

Link: http://lkml.kernel.org/r/55F6E68D.8070800@codeaurora.orgReported-by: default avatarIngo Molnar <mingo@kernel.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@gmail.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: dri-devel <dri-devel@lists.freedesktop.org>
Signed-off-by: default avatarArchit Taneja <architt@codeaurora.org>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent aec9e129
......@@ -220,7 +220,7 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags)
}
r = mgag200_mm_init(mdev);
if (r)
goto out;
goto err_mm;
drm_mode_config_init(dev);
dev->mode_config.funcs = (void *)&mga_mode_funcs;
......@@ -233,7 +233,7 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags)
r = mgag200_modeset_init(mdev);
if (r) {
dev_err(&dev->pdev->dev, "Fatal error during modeset init: %d\n", r);
goto out;
goto err_modeset;
}
/* Make small buffers to store a hardware cursor (double buffered icon updates) */
......@@ -241,20 +241,24 @@ int mgag200_driver_load(struct drm_device *dev, unsigned long flags)
&mdev->cursor.pixels_1);
mgag200_bo_create(dev, roundup(48*64, PAGE_SIZE), 0, 0,
&mdev->cursor.pixels_2);
if (!mdev->cursor.pixels_2 || !mdev->cursor.pixels_1)
goto cursor_nospace;
mdev->cursor.pixels_current = mdev->cursor.pixels_1;
mdev->cursor.pixels_prev = mdev->cursor.pixels_2;
goto cursor_done;
cursor_nospace:
if (!mdev->cursor.pixels_2 || !mdev->cursor.pixels_1) {
mdev->cursor.pixels_1 = NULL;
mdev->cursor.pixels_2 = NULL;
dev_warn(&dev->pdev->dev, "Could not allocate space for cursors. Not doing hardware cursors.\n");
cursor_done:
dev_warn(&dev->pdev->dev,
"Could not allocate space for cursors. Not doing hardware cursors.\n");
} else {
mdev->cursor.pixels_current = mdev->cursor.pixels_1;
mdev->cursor.pixels_prev = mdev->cursor.pixels_2;
}
return 0;
err_modeset:
drm_mode_config_cleanup(dev);
mgag200_mm_fini(mdev);
err_mm:
dev->dev_private = NULL;
out:
if (r)
mgag200_driver_unload(dev);
return r;
}
......
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