|
Message-Id: <20200107192555.20606-2-tli@digitalocean.com> Date: Tue, 7 Jan 2020 13:25:54 -0600 From: Tianlin Li <tli@...italocean.com> To: kernel-hardening@...ts.openwall.com, keescook@...omium.org Cc: Alex Deucher <alexander.deucher@....com>, christian.koenig@....com, David1.Zhou@....com, David Airlie <airlied@...ux.ie>, Daniel Vetter <daniel@...ll.ch>, amd-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org, Tianlin Li <tli@...italocean.com> Subject: [PATCH 1/2] drm/radeon: have the callers of set_memory_*() check the return value Have the callers of set_memory_*() in drm/radeon check the return value. Change the return type of the callers properly. Signed-off-by: Tianlin Li <tli@...italocean.com> --- drivers/gpu/drm/radeon/radeon.h | 2 +- drivers/gpu/drm/radeon/radeon_gart.c | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 30e32adc1fc6..a23e58397293 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -661,7 +661,7 @@ struct radeon_gart { }; int radeon_gart_table_ram_alloc(struct radeon_device *rdev); -void radeon_gart_table_ram_free(struct radeon_device *rdev); +int radeon_gart_table_ram_free(struct radeon_device *rdev); int radeon_gart_table_vram_alloc(struct radeon_device *rdev); void radeon_gart_table_vram_free(struct radeon_device *rdev); int radeon_gart_table_vram_pin(struct radeon_device *rdev); diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c index d4d3778d0a98..59039ab602e8 100644 --- a/drivers/gpu/drm/radeon/radeon_gart.c +++ b/drivers/gpu/drm/radeon/radeon_gart.c @@ -71,6 +71,7 @@ int radeon_gart_table_ram_alloc(struct radeon_device *rdev) { void *ptr; + int ret; ptr = pci_alloc_consistent(rdev->pdev, rdev->gart.table_size, &rdev->gart.table_addr); @@ -80,8 +81,16 @@ int radeon_gart_table_ram_alloc(struct radeon_device *rdev) #ifdef CONFIG_X86 if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480 || rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) { - set_memory_uc((unsigned long)ptr, + ret = set_memory_uc((unsigned long)ptr, rdev->gart.table_size >> PAGE_SHIFT); + if (ret) { + pci_free_consistent(rdev->pdev, rdev->gart.table_size, + (void *)rdev->gart.ptr, + rdev->gart.table_addr); + rdev->gart.ptr = NULL; + rdev->gart.table_addr = 0; + return ret; + } } #endif rdev->gart.ptr = ptr; @@ -98,16 +107,20 @@ int radeon_gart_table_ram_alloc(struct radeon_device *rdev) * (r1xx-r3xx, non-pcie r4xx, rs400). These asics require the * gart table to be in system memory. */ -void radeon_gart_table_ram_free(struct radeon_device *rdev) +int radeon_gart_table_ram_free(struct radeon_device *rdev) { + int ret; + if (rdev->gart.ptr == NULL) { - return; + return 0; } #ifdef CONFIG_X86 if (rdev->family == CHIP_RS400 || rdev->family == CHIP_RS480 || rdev->family == CHIP_RS690 || rdev->family == CHIP_RS740) { - set_memory_wb((unsigned long)rdev->gart.ptr, + ret = set_memory_wb((unsigned long)rdev->gart.ptr, rdev->gart.table_size >> PAGE_SHIFT); + if (ret) + return ret; } #endif pci_free_consistent(rdev->pdev, rdev->gart.table_size, @@ -115,6 +128,7 @@ void radeon_gart_table_ram_free(struct radeon_device *rdev) rdev->gart.table_addr); rdev->gart.ptr = NULL; rdev->gart.table_addr = 0; + return 0; } /** -- 2.17.1
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.