Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11909587ybi; Fri, 26 Jul 2019 01:38:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0rOYTzgGX4qxPqqfTT+XMi5teat8SdZ+Z5uCuLcMXHsQANKfKhrw7TH9BiwZo95gUVo06 X-Received: by 2002:a17:90b:d8b:: with SMTP id bg11mr97055917pjb.30.1564130302972; Fri, 26 Jul 2019 01:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564130302; cv=none; d=google.com; s=arc-20160816; b=iFJQmwW4dU3h/TpcXaBG/gqbsvdJ6GODTp0hDcmmkIJcPIHawhfCmt6rJzJ0hK8xyf TBxlc1Q4AVDAWVFCRtcLpfsnTPZ0lE1dzgGTu4GC4Jy4R4P7hWlsavMZVRWQn2BjyYx5 SiEP3fx2EPrUFBK1Sa4eLEvx6jsmuOXdOeJYCDo/E0YYWg3AO9jWfDYqVoPc1zEjlnti tvGmQsOJu14zVy2SuiUOyyBZ9G2Tlbik3r8Q5chN1+VwDzZENVMWPvno+sfZkYbTH10L yYtwF77D7Vn+nsfhUwKh5Ji1774aIocRQk6ztwMuRJEYI9hyXhH/kQKJXYwgWBfXclIk p9og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version; bh=+QkrjFR6OfsmmDFnir+7sMOzHzgjUhkdpslZiO/CzBg=; b=en7dghq5cD6yql3cloDRfPyGlW3wUyQ3DT/kPVTsEN7DjQ1jZogoa3/EzrgHrGlHgu pNsH55jO7gbR209Sqre/ztKnFHqiA2LbLWHDId5ivOJZa+t92ajZtXBHlCau/CsU4FFf rzKy+JT8omZCKrm3L71shxhxJTEEI6Ue21kfitUIa6WZAUHumwmXg44bslhJ6VnQbiaB mhje8QJqu9P8hCOQTeNHiYYD0/fCxCzfzoHDo/aVuikaOFlsa/k1jvSuBd3h7f0CmUEr 66kAhScFyM/2bbCuW+n++d52mts0yhU2dOf5W8p+rHmHqsePbZ5bKg4OJsqqSJc2greW Jblw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s66si20169373pgs.592.2019.07.26.01.38.07; Fri, 26 Jul 2019 01:38:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726435AbfGZIhP convert rfc822-to-8bit (ORCPT + 99 others); Fri, 26 Jul 2019 04:37:15 -0400 Received: from mail.fireflyinternet.com ([109.228.58.192]:62992 "EHLO fireflyinternet.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725842AbfGZIhO (ORCPT ); Fri, 26 Jul 2019 04:37:14 -0400 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from localhost (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP (TLS) id 17620769-1500050 for multiple; Fri, 26 Jul 2019 09:37:08 +0100 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Chenbo Feng , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org From: Chris Wilson In-Reply-To: <20190613223408.139221-3-fengc@google.com> Cc: Sumit Semwal , kernel-team@android.com References: <20190613223408.139221-1-fengc@google.com> <20190613223408.139221-3-fengc@google.com> Message-ID: <156413022619.30723.12163288418173479775@skylake-alporthouse-com> User-Agent: alot/0.6 Subject: Re: [PATCH v5 2/3] dma-buf: add DMA_BUF_SET_NAME ioctls Date: Fri, 26 Jul 2019 09:37:06 +0100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Chenbo Feng (2019-06-13 23:34:07) > From: Greg Hackmann > > This patch adds complimentary DMA_BUF_SET_NAME ioctls, which lets > userspace processes attach a free-form name to each buffer. > > This information can be extremely helpful for tracking and accounting > shared buffers. For example, on Android, we know what each buffer will > be used for at allocation time: GL, multimedia, camera, etc. The > userspace allocator can use DMA_BUF_SET_NAME to associate that > information with the buffer, so we can later give developers a > breakdown of how much memory they're allocating for graphics, camera, > etc. The name was never freed... diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index d56993238501..0106b96da585 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -104,6 +104,8 @@ static int dma_buf_release(struct inode *inode, struct file *file) list_del(&dmabuf->list_node); mutex_unlock(&db_list.lock); + kfree(dmabuf->name); + if (dmabuf->resv == (struct reservation_object *)&dmabuf[1]) reservation_object_fini(dmabuf->resv); This trusts that access to the name via the fs is serialised by the refcount. It would have been great if the inode would only be allocated for a named dmabuf, but I expect that requires replacing struct file after it is exposed (but maybe a struct file can be moved between fs?). -Chris