From 41a83dc17c49d3bbac1b5e8c98edf8abce47e8c7 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Fri, 10 Feb 2012 13:04:59 -0500 Subject: [PATCH] radeon: fix crash in drmmode_create_bo_pixmap() Only init surface on r6xx+. Return NULL rather than FALSE. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=45829 Signed-off-by: Alex Deucher --- src/drmmode_display.c | 60 +++++++++++++++++++++++++----------------------- 1 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 89ac6d7..7fa89de 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -71,35 +71,37 @@ static PixmapPtr drmmode_create_bo_pixmap(ScrnInfoPtr pScrn, exaMoveInPixmap(pixmap); radeon_set_pixmap_bo(pixmap, bo); - surface = radeon_get_pixmap_surface(pixmap); - if (surface) { - memset(surface, 0, sizeof(struct radeon_surface)); - surface->npix_x = width; - surface->npix_y = height; - surface->npix_z = 1; - surface->blk_w = 1; - surface->blk_h = 1; - surface->blk_d = 1; - surface->array_size = 1; - surface->last_level = 0; - surface->bpe = bpp / 8; - surface->nsamples = 1; - surface->flags = RADEON_SURF_SCANOUT; - surface->flags |= RADEON_SURF_SET(RADEON_SURF_TYPE_2D, TYPE); - surface->flags |= RADEON_SURF_SET(RADEON_SURF_MODE_LINEAR, MODE); - if (tiling & RADEON_TILING_MICRO) { - surface->flags = RADEON_SURF_CLR(surface->flags, MODE); - surface->flags |= RADEON_SURF_SET(RADEON_SURF_MODE_1D, MODE); - } - if (tiling & RADEON_TILING_MACRO) { - surface->flags = RADEON_SURF_CLR(surface->flags, MODE); - surface->flags |= RADEON_SURF_SET(RADEON_SURF_MODE_2D, MODE); - } - if (radeon_surface_best(info->surf_man, surface)) { - return FALSE; - } - if (radeon_surface_init(info->surf_man, surface)) { - return FALSE; + if (info->ChipFamily >= CHIP_FAMILY_R600) { + surface = radeon_get_pixmap_surface(pixmap); + if (surface) { + memset(surface, 0, sizeof(struct radeon_surface)); + surface->npix_x = width; + surface->npix_y = height; + surface->npix_z = 1; + surface->blk_w = 1; + surface->blk_h = 1; + surface->blk_d = 1; + surface->array_size = 1; + surface->last_level = 0; + surface->bpe = bpp / 8; + surface->nsamples = 1; + surface->flags = RADEON_SURF_SCANOUT; + surface->flags |= RADEON_SURF_SET(RADEON_SURF_TYPE_2D, TYPE); + surface->flags |= RADEON_SURF_SET(RADEON_SURF_MODE_LINEAR, MODE); + if (tiling & RADEON_TILING_MICRO) { + surface->flags = RADEON_SURF_CLR(surface->flags, MODE); + surface->flags |= RADEON_SURF_SET(RADEON_SURF_MODE_1D, MODE); + } + if (tiling & RADEON_TILING_MACRO) { + surface->flags = RADEON_SURF_CLR(surface->flags, MODE); + surface->flags |= RADEON_SURF_SET(RADEON_SURF_MODE_2D, MODE); + } + if (radeon_surface_best(info->surf_man, surface)) { + return NULL; + } + if (radeon_surface_init(info->surf_man, surface)) { + return NULL; + } } } -- 1.7.3.4