Use kvfree() to free bo->sgts, because the memory is allocated with
kvmalloc_array().
Fixes: 187d2929206e ("drm/panfrost: Add support for GPU heap allocations")
Cc: [email protected]
Signed-off-by: Denis Efremov <[email protected]>
---
drivers/gpu/drm/panfrost/panfrost_mmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c
index ed28aeba6d59..3c8ae7411c80 100644
--- a/drivers/gpu/drm/panfrost/panfrost_mmu.c
+++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c
@@ -486,7 +486,7 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as,
pages = kvmalloc_array(bo->base.base.size >> PAGE_SHIFT,
sizeof(struct page *), GFP_KERNEL | __GFP_ZERO);
if (!pages) {
- kfree(bo->sgts);
+ kvfree(bo->sgts);
bo->sgts = NULL;
mutex_unlock(&bo->base.pages_lock);
ret = -ENOMEM;
--
2.26.2
On 05/06/2020 19:52, Denis Efremov wrote:
> Use kvfree() to free bo->sgts, because the memory is allocated with
> kvmalloc_array().
>
> Fixes: 187d2929206e ("drm/panfrost: Add support for GPU heap allocations")
> Cc: [email protected]
> Signed-off-by: Denis Efremov <[email protected]>
Well spotted, but there's another one in panfrost_gem_free_object().
Please can you fix that at the same time?
Thanks,
Steve
> ---
> drivers/gpu/drm/panfrost/panfrost_mmu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c
> index ed28aeba6d59..3c8ae7411c80 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c
> @@ -486,7 +486,7 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as,
> pages = kvmalloc_array(bo->base.base.size >> PAGE_SHIFT,
> sizeof(struct page *), GFP_KERNEL | __GFP_ZERO);
> if (!pages) {
> - kfree(bo->sgts);
> + kvfree(bo->sgts);
> bo->sgts = NULL;
> mutex_unlock(&bo->base.pages_lock);
> ret = -ENOMEM;
>
Use kvfree() to free bo->sgts, because the memory is allocated with
kvmalloc_array() in panfrost_mmu_map_fault_addr().
Fixes: 187d2929206e ("drm/panfrost: Add support for GPU heap allocations")
Cc: [email protected]
Signed-off-by: Denis Efremov <[email protected]>
---
Change in v2:
- kvfree() fixed in panfrost_gem_free_object(), thanks to Steven Price
drivers/gpu/drm/panfrost/panfrost_gem.c | 2 +-
drivers/gpu/drm/panfrost/panfrost_mmu.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c
index 17b654e1eb94..556181ea4a07 100644
--- a/drivers/gpu/drm/panfrost/panfrost_gem.c
+++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
@@ -46,7 +46,7 @@ static void panfrost_gem_free_object(struct drm_gem_object *obj)
sg_free_table(&bo->sgts[i]);
}
}
- kfree(bo->sgts);
+ kvfree(bo->sgts);
}
drm_gem_shmem_free_object(obj);
diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c
index ed28aeba6d59..3c8ae7411c80 100644
--- a/drivers/gpu/drm/panfrost/panfrost_mmu.c
+++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c
@@ -486,7 +486,7 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as,
pages = kvmalloc_array(bo->base.base.size >> PAGE_SHIFT,
sizeof(struct page *), GFP_KERNEL | __GFP_ZERO);
if (!pages) {
- kfree(bo->sgts);
+ kvfree(bo->sgts);
bo->sgts = NULL;
mutex_unlock(&bo->base.pages_lock);
ret = -ENOMEM;
--
2.26.2
On 08/06/2020 16:17, Denis Efremov wrote:
> Use kvfree() to free bo->sgts, because the memory is allocated with
> kvmalloc_array() in panfrost_mmu_map_fault_addr().
>
> Fixes: 187d2929206e ("drm/panfrost: Add support for GPU heap allocations")
> Cc: [email protected]
> Signed-off-by: Denis Efremov <[email protected]>
Reviewed-by: Steven Price <[email protected]>
Thanks,
Steve
> ---
> Change in v2:
> - kvfree() fixed in panfrost_gem_free_object(), thanks to Steven Price
>
> drivers/gpu/drm/panfrost/panfrost_gem.c | 2 +-
> drivers/gpu/drm/panfrost/panfrost_mmu.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c
> index 17b654e1eb94..556181ea4a07 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_gem.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
> @@ -46,7 +46,7 @@ static void panfrost_gem_free_object(struct drm_gem_object *obj)
> sg_free_table(&bo->sgts[i]);
> }
> }
> - kfree(bo->sgts);
> + kvfree(bo->sgts);
> }
>
> drm_gem_shmem_free_object(obj);
> diff --git a/drivers/gpu/drm/panfrost/panfrost_mmu.c b/drivers/gpu/drm/panfrost/panfrost_mmu.c
> index ed28aeba6d59..3c8ae7411c80 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_mmu.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_mmu.c
> @@ -486,7 +486,7 @@ static int panfrost_mmu_map_fault_addr(struct panfrost_device *pfdev, int as,
> pages = kvmalloc_array(bo->base.base.size >> PAGE_SHIFT,
> sizeof(struct page *), GFP_KERNEL | __GFP_ZERO);
> if (!pages) {
> - kfree(bo->sgts);
> + kvfree(bo->sgts);
> bo->sgts = NULL;
> mutex_unlock(&bo->base.pages_lock);
> ret = -ENOMEM;
>