From patchwork Wed Sep 17 12:37:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lespiau, Damien" X-Patchwork-Id: 4924231 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CE3479F2EC for ; Wed, 17 Sep 2014 12:36:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C1D820166 for ; Wed, 17 Sep 2014 12:38:10 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 566D220154 for ; Wed, 17 Sep 2014 12:38:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C1BBB6E4C1; Wed, 17 Sep 2014 05:38:03 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id C5B4A6E4C1; Wed, 17 Sep 2014 05:38:02 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 17 Sep 2014 05:31:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,540,1406617200"; d="scan'208";a="604137865" Received: from swisniew-mobl2.ger.corp.intel.com (HELO strange.ger.corp.intel.com) ([10.252.4.22]) by orsmga002.jf.intel.com with ESMTP; 17 Sep 2014 05:37:52 -0700 From: Damien Lespiau To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH] intel: Don't leak the test page in an has_userptr() error path Date: Wed, 17 Sep 2014 13:37:51 +0100 Message-Id: <1410957471-11375-1-git-send-email-damien.lespiau@intel.com> X-Mailer: git-send-email 1.8.3.1 Cc: tvrtko.ursulin@intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 When handling the error on GEM_CLOSE, we weren't freeing the allocated page. Plug that. Signed-off-by: Damien Lespiau Reviewed-by: Tvrtko Ursulin --- intel/intel_bufmgr_gem.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index f378e5c..ce35bd4 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -3383,9 +3383,8 @@ retry: close_bo.handle = userptr.handle; ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_GEM_CLOSE, &close_bo); - if (ret == 0) { - free(ptr); - } else { + free(ptr); + if (ret) { fprintf(stderr, "Failed to release test userptr object! (%d) " "i915 kernel driver may not be sane!\n", errno); return false;