From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:35038 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752078AbcIINny (ORCPT ); Fri, 9 Sep 2016 09:43:54 -0400 Subject: Patch "[PATCH 111/135] drm: Balance error path for GEM handle allocation" has been added to the 4.4-stable tree To: chris@chris-wilson.co.uk, alexander.levin@verizon.com, daniel.vetter@ffwll.ch, gregkh@linuxfoundation.org, ville.syrjala@linux.intel.com Cc: , From: Date: Fri, 09 Sep 2016 15:38:37 +0200 Message-ID: <14734283175031@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled [PATCH 111/135] drm: Balance error path for GEM handle allocation to the 4.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: 0111-drm-Balance-error-path-for-GEM-handle-allocation.patch and it can be found in the queue-4.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From 8d8f32644cf6424d7a16f4a9ee83e7d71fd83c75 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 9 May 2016 12:01:27 -0600 Subject: [PATCH 111/135] drm: Balance error path for GEM handle allocation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ Upstream commit 6984128d01cf935820a0563f3a00c6623ba58109 ] The current error path for failure when establishing a handle for a GEM object is unbalance, e.g. we call object_close() without calling first object_open(). Use the typical onion structure to only undo what has been set up prior to the error. Signed-off-by: Chris Wilson Reviewed-by: Ville Syrjälä Signed-off-by: Daniel Vetter Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/drm_gem.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -338,27 +338,32 @@ drm_gem_handle_create_tail(struct drm_fi spin_unlock(&file_priv->table_lock); idr_preload_end(); mutex_unlock(&dev->object_name_lock); - if (ret < 0) { - drm_gem_object_handle_unreference_unlocked(obj); - return ret; - } + if (ret < 0) + goto err_unref; + *handlep = ret; ret = drm_vma_node_allow(&obj->vma_node, file_priv->filp); - if (ret) { - drm_gem_handle_delete(file_priv, *handlep); - return ret; - } + if (ret) + goto err_remove; if (dev->driver->gem_open_object) { ret = dev->driver->gem_open_object(obj, file_priv); - if (ret) { - drm_gem_handle_delete(file_priv, *handlep); - return ret; - } + if (ret) + goto err_revoke; } return 0; + +err_revoke: + drm_vma_node_revoke(&obj->vma_node, file_priv->filp); +err_remove: + spin_lock(&file_priv->table_lock); + idr_remove(&file_priv->object_idr, *handlep); + spin_unlock(&file_priv->table_lock); +err_unref: + drm_gem_object_handle_unreference_unlocked(obj); + return ret; } /** Patches currently in stable-queue which might be from chris@chris-wilson.co.uk are queue-4.4/0131-drm-i915-Check-VBT-for-port-presence-in-addition-to-.patch queue-4.4/0130-drm-i915-Only-ignore-eDP-ports-that-are-connected.patch queue-4.4/0111-drm-Balance-error-path-for-GEM-handle-allocation.patch