From patchwork Sun Jan 22 18:48:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 9531437 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6ED8060431 for ; Sun, 22 Jan 2017 18:50:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6114627F54 for ; Sun, 22 Jan 2017 18:50:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5591827F99; Sun, 22 Jan 2017 18:50:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 23FEF27F54 for ; Sun, 22 Jan 2017 18:50:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1D2A36E34D; Sun, 22 Jan 2017 18:50:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id C10D16E34C; Sun, 22 Jan 2017 18:50:26 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id c85so20876227wmi.1; Sun, 22 Jan 2017 10:50:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7XAWm5VLxnkj3UbGlF8bC830Pg1lTAMjpTQ+1qGkMrQ=; b=K4YDdHUlB30zPjjsNhcT6ulVEB6ebdnfV5SdNIhNWiAPRxcek6GZDmiNWIpAaHYCd8 eVIJIeWlqKLJuD8NYtTF6kEGKhnGwBcA/TYTFB4iA2tkyZi6HdCI/x/AJMK9esjF1M2E crBdhOc0FWGjHUnvtgQMp9JO9Kptbw6Po85xQjVP47l7C+Hfo+/esZWOJIy78hMs1Or8 QOFGXPl+U0tH4P6r0nXjf80VUXa9Ihsz1YPUcN3cGu+wPbik1VVF0NsMpAvF1QxZVCpt l1QKdRJGYa1KY3Vff1CR4XxJ8t5sM2jf1Sn9rgcnJH2vx83wfKbf/PNK0xMdetIOudTl tqSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7XAWm5VLxnkj3UbGlF8bC830Pg1lTAMjpTQ+1qGkMrQ=; b=QPC0Su6DZ3DOfzeelV6B0ofOC2kpjAsOBW8jGfbFWrgsWDVW5KhK1sxnXBTHYhpv6r Y+1LPKKwqi9+/BINmgjK6fUkOE8EowxDk/59yCJ+zLDb5xI+q8uPhrnvTpGf2ynbJp3J dhu/GSSKLqQYaJLWSq/rzrWeE/F8Nw8zcE83J7maxdtw/Watw9YSTaHHjb676y232xVd SgN/9N+KNB2s1KRCojMu6cR3rN79rWD2xZ78A8q0KwAFpVDDppwNueWzoZ/K1GOLDGo0 9k3ZT42wW8ltJp98iKNii3m4/ei34PdbT9tmueMI47UFNsh3yYdkrNecCMcEyi5WGrC3 RzLA== X-Gm-Message-State: AIkVDXLN6OkVivPIZMgtVjTW8dcsFmKadTX8RIG1gyNd2a38NhbLHP1h/xa1W31kIyUTxQ== X-Received: by 10.28.154.70 with SMTP id c67mr12036736wme.90.1485111025195; Sun, 22 Jan 2017 10:50:25 -0800 (PST) Received: from localhost.localdomain (cpc91186-cmbg18-2-0-cust67.5-4.cable.virginm.net. [80.1.50.68]) by smtp.gmail.com with ESMTPSA id z67sm10732776wrb.49.2017.01.22.10.50.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jan 2017 10:50:24 -0800 (PST) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 2/3] amdgpu: don't mess with shared_handle if amdgpu_bo_import() fails Date: Sun, 22 Jan 2017 18:48:12 +0000 Message-Id: <20170122184813.12995-2-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170122184813.12995-1-emil.l.velikov@gmail.com> References: <20170122184813.12995-1-emil.l.velikov@gmail.com> Cc: emil.l.velikov@gmail.com, amd-gfx@lists.freedesktop.org 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-Virus-Scanned: ClamAV using ClamSMTP Do not close the handle if someone else has created it. Afaict there's no change of ownership implied if the function fails. Thus the caller is responsible to doing the right thing - trying again, closing the handle and/or other. Cc: amd-gfx@lists.freedesktop.org Signed-off-by: Emil Velikov --- Not 100% sure if it's the correct thing. --- amdgpu/amdgpu_bo.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c index c9f31587..24fa8880 100644 --- a/amdgpu/amdgpu_bo.c +++ b/amdgpu/amdgpu_bo.c @@ -310,7 +310,6 @@ int amdgpu_bo_import(amdgpu_device_handle dev, size = lseek(shared_handle, 0, SEEK_END); if (size == (off_t)-1) { pthread_mutex_unlock(&dev->bo_table_mutex); - amdgpu_close_kms_handle(dev, handle); return -errno; } lseek(shared_handle, 0, SEEK_SET); @@ -355,9 +354,6 @@ int amdgpu_bo_import(amdgpu_device_handle dev, bo = calloc(1, sizeof(struct amdgpu_bo)); if (!bo) { pthread_mutex_unlock(&dev->bo_table_mutex); - if (type == amdgpu_bo_handle_type_dma_buf_fd) { - amdgpu_close_kms_handle(dev, shared_handle); - } return -ENOMEM; }