[Nouveau] [PATCH] drm/nouveau: properly handle allocation failure in nouveau_sgdma_populate

Konrad Rzeszutek Wilk konrad.wilk at oracle.com
Mon Aug 22 19:52:51 PDT 2011


On Mon, Aug 22, 2011 at 11:14:05PM +0200, Marcin Slusarz wrote:
> Not cleaning after alloc failure would result in crash on destroy,
> because nouveau_sgdma_clear assumes "ttm_alloced" to be not null when
> "pages" is not null.
> 
> Signed-off-by: Marcin Slusarz <marcin.slusarz at gmail.com>
> Cc: stable at kernel.org

Acked-by: Konrad Rzeszutek Wilk <konrad.wilk at oracle.com>

> ---
>  drivers/gpu/drm/nouveau/nouveau_sgdma.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> index 82fad91..ca6028f 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c
> @@ -37,8 +37,11 @@ nouveau_sgdma_populate(struct ttm_backend *be, unsigned long num_pages,
>  		return -ENOMEM;
>  
>  	nvbe->ttm_alloced = kmalloc(sizeof(bool) * num_pages, GFP_KERNEL);
> -	if (!nvbe->ttm_alloced)
> +	if (!nvbe->ttm_alloced) {
> +		kfree(nvbe->pages);
> +		nvbe->pages = NULL;
>  		return -ENOMEM;
> +	}
>  
>  	nvbe->nr_pages = 0;
>  	while (num_pages--) {
> -- 
> 1.7.6
> 
> _______________________________________________
> Nouveau mailing list
> Nouveau at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/nouveau


More information about the Nouveau mailing list