Skip to content

Commit 53dac83

Browse files
committed
drm/mgag200: fix oops in cursor code.
In some cases we enter the cursor code with file_priv = NULL causing an oops, we also can try to unpin something that isn't pinned, and this is a good fix for it. Cc: stable@vger.kernel.org Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent c5416d6 commit 53dac83

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎drivers/gpu/drm/mgag200/mgag200_cursor.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ static void mga_hide_cursor(struct mga_device *mdev)
2222
{
2323
WREG8(MGA_CURPOSXL, 0);
2424
WREG8(MGA_CURPOSXH, 0);
25-
mgag200_bo_unpin(mdev->cursor.pixels_1);
26-
mgag200_bo_unpin(mdev->cursor.pixels_2);
25+
if (mdev->cursor.pixels_1->pin_count)
26+
mgag200_bo_unpin(mdev->cursor.pixels_1);
27+
if (mdev->cursor.pixels_2->pin_count)
28+
mgag200_bo_unpin(mdev->cursor.pixels_2);
2729
}
2830

2931
int mga_crtc_cursor_set(struct drm_crtc *crtc,
@@ -32,7 +34,7 @@ int mga_crtc_cursor_set(struct drm_crtc *crtc,
3234
uint32_t width,
3335
uint32_t height)
3436
{
35-
struct drm_device *dev = (struct drm_device *)file_priv->minor->dev;
37+
struct drm_device *dev = crtc->dev;
3638
struct mga_device *mdev = (struct mga_device *)dev->dev_private;
3739
struct mgag200_bo *pixels_1 = mdev->cursor.pixels_1;
3840
struct mgag200_bo *pixels_2 = mdev->cursor.pixels_2;

0 commit comments

Comments
 (0)