Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.org
Reported-by: Ingo 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: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>

authored by

Archit Taneja and committed by
Dave Airlie
728f8660 aec9e129

+19 -15
+19 -15
drivers/gpu/drm/mgag200/mgag200_main.c
··· 220 220 } 221 221 r = mgag200_mm_init(mdev); 222 222 if (r) 223 - goto out; 223 + goto err_mm; 224 224 225 225 drm_mode_config_init(dev); 226 226 dev->mode_config.funcs = (void *)&mga_mode_funcs; ··· 233 233 r = mgag200_modeset_init(mdev); 234 234 if (r) { 235 235 dev_err(&dev->pdev->dev, "Fatal error during modeset init: %d\n", r); 236 - goto out; 236 + goto err_modeset; 237 237 } 238 238 239 239 /* Make small buffers to store a hardware cursor (double buffered icon updates) */ ··· 241 241 &mdev->cursor.pixels_1); 242 242 mgag200_bo_create(dev, roundup(48*64, PAGE_SIZE), 0, 0, 243 243 &mdev->cursor.pixels_2); 244 - if (!mdev->cursor.pixels_2 || !mdev->cursor.pixels_1) 245 - goto cursor_nospace; 246 - mdev->cursor.pixels_current = mdev->cursor.pixels_1; 247 - mdev->cursor.pixels_prev = mdev->cursor.pixels_2; 248 - goto cursor_done; 249 - cursor_nospace: 250 - mdev->cursor.pixels_1 = NULL; 251 - mdev->cursor.pixels_2 = NULL; 252 - dev_warn(&dev->pdev->dev, "Could not allocate space for cursors. Not doing hardware cursors.\n"); 253 - cursor_done: 244 + if (!mdev->cursor.pixels_2 || !mdev->cursor.pixels_1) { 245 + mdev->cursor.pixels_1 = NULL; 246 + mdev->cursor.pixels_2 = NULL; 247 + dev_warn(&dev->pdev->dev, 248 + "Could not allocate space for cursors. Not doing hardware cursors.\n"); 249 + } else { 250 + mdev->cursor.pixels_current = mdev->cursor.pixels_1; 251 + mdev->cursor.pixels_prev = mdev->cursor.pixels_2; 252 + } 254 253 255 - out: 256 - if (r) 257 - mgag200_driver_unload(dev); 254 + return 0; 255 + 256 + err_modeset: 257 + drm_mode_config_cleanup(dev); 258 + mgag200_mm_fini(mdev); 259 + err_mm: 260 + dev->dev_private = NULL; 261 + 258 262 return r; 259 263 } 260 264