From patchwork Wed Aug 28 10:04:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 2850612 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3ED23BF546 for ; Wed, 28 Aug 2013 10:05:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7C26D2020F for ; Wed, 28 Aug 2013 10:05:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A9F88201F6 for ; Wed, 28 Aug 2013 10:05:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E2B1E7836 for ; Wed, 28 Aug 2013 03:05:35 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-bk0-f50.google.com (mail-bk0-f50.google.com [209.85.214.50]) by gabe.freedesktop.org (Postfix) with ESMTP id CBBECE6158 for ; Wed, 28 Aug 2013 03:04:47 -0700 (PDT) Received: by mail-bk0-f50.google.com with SMTP id mz11so2136869bkb.9 for ; Wed, 28 Aug 2013 03:04:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=gihSYfgND7Lb7ms1/GY3tOhoPZ2vjQiEPnIF/k1x+As=; b=vs4vk6F37+LDBCYaGVmqfI5+sFnRYDhoQ7dikA0z0+dA8bIJm05tEKj3k2eYXdctS0 y/4h4DZths2nlrVYYtQjAcCuMZwd4XakW4ERUZGfoK6lk6EAWwzIzqkC38qtLFb1UtVH CAmQLnII9I028wBhOlpL+c3vrb08ho2xUCMHdIPMntlmT9oSaapnAETKeF9s7K4VoWb5 h28Xyc5sbTscWapZdnXvLvo0dmka1QqaAHe9m2I3Fa2iql8pcmkz6Jl6xH5qdt6zH0Pt xXTlBm1Nh5W24tF0tWKctopsOVXvAqk0FgOEvmXYnl4aylUtgajUXxetzXAtuuDcbqKz /x3g== X-Received: by 10.205.14.197 with SMTP id pr5mr10702791bkb.25.1377684286894; Wed, 28 Aug 2013 03:04:46 -0700 (PDT) Received: from localhost (port-14330.pppoe.wtnet.de. [84.46.56.50]) by mx.google.com with ESMTPSA id h5sm5625775bkg.8.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 28 Aug 2013 03:04:46 -0700 (PDT) From: Thierry Reding To: David Airlie Subject: [PATCH] drm/prime: Remove PRIME handles only if supported Date: Wed, 28 Aug 2013 12:04:14 +0200 Message-Id: <1377684254-17117-1-git-send-email-treding@nvidia.com> X-Mailer: git-send-email 1.8.4 Cc: Daniel Vetter , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Drivers that don't support PRIME will not have initialized the PRIME specific private component of struct drm_file. If called for such drivers, the drm_gem_remove_prime_handles() function will crash. Fix it by checking for PRIME support prior to removing the PRIME handles. Signed-off-by: Thierry Reding --- drivers/gpu/drm/drm_gem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 1ce88c3..4a23f34 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -296,7 +296,8 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle) idr_remove(&filp->object_idr, handle); spin_unlock(&filp->table_lock); - drm_gem_remove_prime_handles(obj, filp); + if (drm_core_check_feature(dev, DRIVER_PRIME)) + drm_gem_remove_prime_handles(obj, filp); if (dev->driver->gem_close_object) dev->driver->gem_close_object(obj, filp); @@ -699,7 +700,8 @@ drm_gem_object_release_handle(int id, void *ptr, void *data) struct drm_gem_object *obj = ptr; struct drm_device *dev = obj->dev; - drm_gem_remove_prime_handles(obj, file_priv); + if (drm_core_check_feature(dev, DRIVER_PRIME)) + drm_gem_remove_prime_handles(obj, file_priv); if (dev->driver->gem_close_object) dev->driver->gem_close_object(obj, file_priv);