linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Eric Anholt <eric@anholt.net>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2 RESEND] drm/vc4: Fix OOPSes from trying to cache a partially constructed BO.
Date: Thu, 2 Mar 2017 09:14:56 +0100	[thread overview]
Message-ID: <20170302091456.7a46b592@bbrezillon> (raw)
In-Reply-To: <20170301185602.6873-2-eric@anholt.net>

On Wed,  1 Mar 2017 10:56:02 -0800
Eric Anholt <eric@anholt.net> wrote:

> If a CMA allocation failed, the partially constructed BO would be
> unreferenced through the normal path, and we might choose to put it in
> the BO cache.  If we then reused it before it expired from the cache,
> the kernel would OOPS.
> 
> Signed-off-by: Eric Anholt <eric@anholt.net>
> Fixes: c826a6e10644 ("drm/vc4: Add a BO cache.")

Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>

> ---
>  drivers/gpu/drm/vc4/vc4_bo.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c
> index e5c7aa935b4b..af29432a6471 100644
> --- a/drivers/gpu/drm/vc4/vc4_bo.c
> +++ b/drivers/gpu/drm/vc4/vc4_bo.c
> @@ -317,6 +317,14 @@ void vc4_free_object(struct drm_gem_object *gem_bo)
>  		goto out;
>  	}
>  
> +	/* If this object was partially constructed but CMA allocation
> +	 * had failed, just free it.
> +	 */
> +	if (!bo->base.vaddr) {
> +		vc4_bo_destroy(bo);
> +		goto out;
> +	}
> +
>  	cache_list = vc4_get_cache_list_for_size(dev, gem_bo->size);
>  	if (!cache_list) {
>  		vc4_bo_destroy(bo);

  reply	other threads:[~2017-03-02  8:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-01 18:56 [PATCH 1/2 RESEND] drm/vc4: Fulfill user BO creation requests from the kernel BO cache Eric Anholt
2017-03-01 18:56 ` [PATCH 2/2 RESEND] drm/vc4: Fix OOPSes from trying to cache a partially constructed BO Eric Anholt
2017-03-02  8:14   ` Boris Brezillon [this message]
2017-03-02  8:08 ` [PATCH 1/2 RESEND] drm/vc4: Fulfill user BO creation requests from the kernel BO cache Boris Brezillon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170302091456.7a46b592@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eric@anholt.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).