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

drm/gma500/cdv: Fix cursor gem obj referencing on cdv

The internal crtc cursor gem object pointer was never set/updated since
it was required to be set in the first place.

Fixing this will make the pin/unpin count match and prevent cursor
objects from leaking when userspace drops all references to it. Also
make sure we drop the gem obj reference on failure.

This patch only affects Cedarview chips.

Signed-off-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>

+11 -5
+11 -5
drivers/gpu/drm/gma500/cdv_intel_display.c
··· 1462 1462 size_t addr = 0; 1463 1463 struct gtt_range *gt; 1464 1464 struct drm_gem_object *obj; 1465 - int ret; 1465 + int ret = 0; 1466 1466 1467 1467 /* if we want to turn of the cursor ignore width and height */ 1468 1468 if (!handle) { ··· 1499 1499 1500 1500 if (obj->size < width * height * 4) { 1501 1501 dev_dbg(dev->dev, "buffer is to small\n"); 1502 - return -ENOMEM; 1502 + ret = -ENOMEM; 1503 + goto unref_cursor; 1503 1504 } 1504 1505 1505 1506 gt = container_of(obj, struct gtt_range, gem); ··· 1509 1508 ret = psb_gtt_pin(gt); 1510 1509 if (ret) { 1511 1510 dev_err(dev->dev, "Can not pin down handle 0x%x\n", handle); 1512 - return ret; 1511 + goto unref_cursor; 1513 1512 } 1514 1513 1515 1514 addr = gt->offset; /* Or resource.start ??? */ ··· 1533 1532 struct gtt_range, gem); 1534 1533 psb_gtt_unpin(gt); 1535 1534 drm_gem_object_unreference(psb_intel_crtc->cursor_obj); 1536 - psb_intel_crtc->cursor_obj = obj; 1537 1535 } 1538 - return 0; 1536 + 1537 + psb_intel_crtc->cursor_obj = obj; 1538 + return ret; 1539 + 1540 + unref_cursor: 1541 + drm_gem_object_unreference(obj); 1542 + return ret; 1539 1543 } 1540 1544 1541 1545 static int cdv_intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)