From patchwork Mon Jul 13 13:39:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 6779381 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8246F9F2E8 for ; Mon, 13 Jul 2015 13:35:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A685820634 for ; Mon, 13 Jul 2015 13:35:10 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C55EE20498 for ; Mon, 13 Jul 2015 13:35:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 74AC26E191; Mon, 13 Jul 2015 06:35:08 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com [74.125.82.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0C1936E191; Mon, 13 Jul 2015 06:35:07 -0700 (PDT) Received: by wgkl9 with SMTP id l9so26115906wgk.1; Mon, 13 Jul 2015 06:35:05 -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=+3HxmJfMTRnESIpeuS8SkUG4/ryYgEyrhvgXjBZF8z4=; b=msbmiLZnQVskbAKG4BRX69O5iGT039BoUMR4f/KaAbQzAEPqYESu/akHuV53XjFN5l Uh0QZhCUDkEPpItLhsq3xCAYcStftDlt/B/Gvph0kqc9IMxgry9KhOubHQC9ewweJzb7 OnzxYhnE9DTtAQeCfXGOUl7hJJDFVIu+IM8noOSYpI2ZA9IcbvfUzpZ3xLcRTIPUPKG6 6RqttQDeRf3hH0ktcAYBGBIRkBJTWw+hBLgyN3HtWCMgqpVaEr+b8dx72K5qytoBT1bF l3WPT/8R468mxOjRcvW17+GXFWOz6UaZ96idD9RtUa0LQna2ABM7703oGfdipLCH3ysc cTSg== X-Received: by 10.180.9.6 with SMTP id v6mr23142793wia.83.1436794505345; Mon, 13 Jul 2015 06:35:05 -0700 (PDT) Received: from arch-x220.localdomain (cpc12-croy20-2-0-cust52.croy.cable.virginm.net. [82.44.54.53]) by smtp.gmail.com with ESMTPSA id pd7sm29258072wjb.27.2015.07.13.06.35.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Jul 2015 06:35:04 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm] freedreno: zero is a valid fd number, treat it as such Date: Mon, 13 Jul 2015 14:39:05 +0100 Message-Id: <1436794745-19525-1-git-send-email-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.4.5 Cc: freedreno@lists.freedesktop.org, emil.l.velikov@gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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=-5.5 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 Abeit quite unlikely to get hit by this bug here, let just fix it. Cc: freedreno@lists.freedesktop.org Cc: Rob Clark Signed-off-by: Emil Velikov --- freedreno/freedreno_bo.c | 6 +++--- freedreno/kgsl/kgsl_bo.c | 1 + freedreno/msm/msm_bo.c | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/freedreno/freedreno_bo.c b/freedreno/freedreno_bo.c index 517a2f8..ffaef4c 100644 --- a/freedreno/freedreno_bo.c +++ b/freedreno/freedreno_bo.c @@ -285,9 +285,9 @@ void fd_bo_del(struct fd_bo *bo) if (!atomic_dec_and_test(&bo->refcnt)) return; - if (bo->fd) { + if (bo->fd >= 0) { close(bo->fd); - bo->fd = 0; + bo->fd = -1; } pthread_mutex_lock(&table_lock); @@ -372,7 +372,7 @@ uint32_t fd_bo_handle(struct fd_bo *bo) int fd_bo_dmabuf(struct fd_bo *bo) { - if (!bo->fd) { + if (bo->fd >= 0) { struct drm_prime_handle req = { .handle = bo->handle, .flags = DRM_CLOEXEC, diff --git a/freedreno/kgsl/kgsl_bo.c b/freedreno/kgsl/kgsl_bo.c index 15c3ff5..3407c76 100644 --- a/freedreno/kgsl/kgsl_bo.c +++ b/freedreno/kgsl/kgsl_bo.c @@ -168,6 +168,7 @@ drm_private struct fd_bo * kgsl_bo_from_handle(struct fd_device *dev, bo = &kgsl_bo->base; bo->funcs = &funcs; + bo->fd = -1; for (i = 0; i < ARRAY_SIZE(kgsl_bo->list); i++) list_inithead(&kgsl_bo->list[i]); diff --git a/freedreno/msm/msm_bo.c b/freedreno/msm/msm_bo.c index fbd82df..3f5b6d0 100644 --- a/freedreno/msm/msm_bo.c +++ b/freedreno/msm/msm_bo.c @@ -137,6 +137,7 @@ drm_private struct fd_bo * msm_bo_from_handle(struct fd_device *dev, bo = &msm_bo->base; bo->funcs = &funcs; + bo->fd = -1; for (i = 0; i < ARRAY_SIZE(msm_bo->list); i++) list_inithead(&msm_bo->list[i]);