public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: YueHaibing <yuehaibing@huawei.com>
Cc: maarten.lankhorst@linux.intel.com, maxime.ripard@bootlin.com,
	sean@poorly.run, airlied@linux.ie, daniel@ffwll.ch,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH -next] drm: Fix error handling in drm_legacy_addctx
Date: Mon, 7 Jan 2019 11:26:55 +0100	[thread overview]
Message-ID: <20190107102655.GD21184@phenom.ffwll.local> (raw)
In-Reply-To: <20181229024907.12852-1-yuehaibing@huawei.com>

On Sat, Dec 29, 2018 at 10:49:07AM +0800, YueHaibing wrote:
> 'ctx->handle' is unsigned, it never less than zero.
> This patch use int 'tmp_handle' to handle the err condition.
> 
> Fixes: 62968144e673 ("drm: convert drm context code to use Linux idr")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Queue for 5.1 (since this is essentially dead legacy code there's no
really a need to backport this).
-Daniel

> ---
>  drivers/gpu/drm/drm_context.c | 15 +++++++++------
>  1 file changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
> index 506663c..8e73fab 100644
> --- a/drivers/gpu/drm/drm_context.c
> +++ b/drivers/gpu/drm/drm_context.c
> @@ -361,23 +361,26 @@ int drm_legacy_addctx(struct drm_device *dev, void *data,
>  {
>  	struct drm_ctx_list *ctx_entry;
>  	struct drm_ctx *ctx = data;
> +	int tmp_handle;
>  
>  	if (!drm_core_check_feature(dev, DRIVER_KMS_LEGACY_CONTEXT) &&
>  	    !drm_core_check_feature(dev, DRIVER_LEGACY))
>  		return -EOPNOTSUPP;
>  
> -	ctx->handle = drm_legacy_ctxbitmap_next(dev);
> -	if (ctx->handle == DRM_KERNEL_CONTEXT) {
> +	tmp_handle = drm_legacy_ctxbitmap_next(dev);
> +	if (tmp_handle == DRM_KERNEL_CONTEXT) {
>  		/* Skip kernel's context and get a new one. */
> -		ctx->handle = drm_legacy_ctxbitmap_next(dev);
> +		tmp_handle = drm_legacy_ctxbitmap_next(dev);
>  	}
> -	DRM_DEBUG("%d\n", ctx->handle);
> -	if (ctx->handle < 0) {
> +	DRM_DEBUG("%d\n", tmp_handle);
> +	if (tmp_handle < 0) {
>  		DRM_DEBUG("Not enough free contexts.\n");
>  		/* Should this return -EBUSY instead? */
> -		return -ENOMEM;
> +		return tmp_handle;
>  	}
>  
> +	ctx->handle = tmp_handle;
> +
>  	ctx_entry = kmalloc(sizeof(*ctx_entry), GFP_KERNEL);
>  	if (!ctx_entry) {
>  		DRM_DEBUG("out of memory\n");
> -- 
> 2.7.0
> 
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

      reply	other threads:[~2019-01-07 10:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-29  2:49 [PATCH -next] drm: Fix error handling in drm_legacy_addctx YueHaibing
2019-01-07 10:26 ` Daniel Vetter [this message]

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=20190107102655.GD21184@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=maxime.ripard@bootlin.com \
    --cc=sean@poorly.run \
    --cc=yuehaibing@huawei.com \
    /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