<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/dma-buf/sync_file.c, branch v4.14.263</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v4.14.263</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v4.14.263'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2021-07-28T09:12:16+00:00</updated>
<entry>
<title>dma-buf/sync_file: Don't leak fences on merge failure</title>
<updated>2021-07-28T09:12:16+00:00</updated>
<author>
<name>Jason Ekstrand</name>
<email>jason@jlekstrand.net</email>
</author>
<published>2021-06-24T17:47:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=19f51c2529339280d2c8c6427cd3e21ddf1ac3f8'/>
<id>urn:sha1:19f51c2529339280d2c8c6427cd3e21ddf1ac3f8</id>
<content type='text'>
commit ffe000217c5068c5da07ccb1c0f8cce7ad767435 upstream.

Each add_fence() call does a dma_fence_get() on the relevant fence.  In
the error path, we weren't calling dma_fence_put() so all those fences
got leaked.  Also, in the krealloc_array failure case, we weren't
freeing the fences array.  Instead, ensure that i and fences are always
zero-initialized and dma_fence_put() all the fences and kfree(fences) on
every error path.

Signed-off-by: Jason Ekstrand &lt;jason@jlekstrand.net&gt;
Reviewed-by: Christian König &lt;christian.koenig@amd.com&gt;
Fixes: a02b9dc90d84 ("dma-buf/sync_file: refactor fence storage in struct sync_file")
Cc: Gustavo Padovan &lt;gustavo.padovan@collabora.co.uk&gt;
Cc: Christian König &lt;christian.koenig@amd.com&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20210624174732.1754546-1-jason@jlekstrand.net
Signed-off-by: Christian König &lt;christian.koenig@amd.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>dma-buf: Fix memory leak in sync_file_merge()</title>
<updated>2019-12-21T09:47:50+00:00</updated>
<author>
<name>Navid Emamdoost</name>
<email>navid.emamdoost@gmail.com</email>
</author>
<published>2019-11-22T22:09:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=490d242d6c725ab5e3bb45d507eb81c5dd5b418a'/>
<id>urn:sha1:490d242d6c725ab5e3bb45d507eb81c5dd5b418a</id>
<content type='text'>
commit 6645d42d79d33e8a9fe262660a75d5f4556bbea9 upstream.

In the implementation of sync_file_merge() the allocated sync_file is
leaked if number of fences overflows. Release sync_file by goto err.

Fixes: a02b9dc90d84 ("dma-buf/sync_file: refactor fence storage in struct sync_file")
Signed-off-by: Navid Emamdoost &lt;navid.emamdoost@gmail.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Vetter &lt;daniel.vetter@ffwll.ch&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20191122220957.30427-1-navid.emamdoost@gmail.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>sync_file: Return consistent status in SYNC_IOC_FILE_INFO</title>
<updated>2017-10-09T16:09:19+00:00</updated>
<author>
<name>John Einar Reitan</name>
<email>john.reitan@arm.com</email>
</author>
<published>2017-10-09T13:49:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f7974880cf869ddbd0ba9a8e2ab11dff4a667f96'/>
<id>urn:sha1:f7974880cf869ddbd0ba9a8e2ab11dff4a667f96</id>
<content type='text'>
sync_file_ioctl_fence_info has a race between filling the status
of the underlying fences and the overall status of the sync_file.
If fence transitions in the time frame between its sync_fill_fence_info
and the later dma_fence_is_signaled for the sync_file, the returned
information is inconsistent showing non-signaled underlying fences but
an overall signaled state.

This patch changes sync_file_ioctl_fence_info to track what has been
encoded and using that as the overall sync_file status.

Tested-by: Vamsidhar Reddy Gaddam &lt;vamsidhar.gaddam@arm.com&gt;
Signed-off-by: John Einar Reitan &lt;john.reitan@arm.com&gt;
Cc: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Cc: Gustavo Padovan &lt;gustavo@padovan.org&gt;
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Chris Wilson &lt;chris@chris-wilson.co.uk&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.com&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20171009134936.27219-1-john.reitan@arm.com
</content>
</entry>
<entry>
<title>dma-buf/sync_file: Allow multiple sync_files to wrap a single dma-fence</title>
<updated>2017-07-31T13:55:24+00:00</updated>
<author>
<name>Chris Wilson</name>
<email>chris@chris-wilson.co.uk</email>
</author>
<published>2017-07-28T21:29:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=99f828436788f0155798145853607ca8f0e6de93'/>
<id>urn:sha1:99f828436788f0155798145853607ca8f0e6de93</id>
<content type='text'>
Up until recently sync_file were create to export a single dma-fence to
userspace, and so we could canabalise a bit insie dma-fence to mark
whether or not we had enable polling for the sync_file itself. However,
with the advent of syncobj, we do allow userspace to create multiple
sync_files for a single dma-fence. (Similarly, that the sw-sync
validation framework also started returning multiple sync-files wrapping
a single dma-fence for a syncpt also triggering the problem.)

This patch reverts my suggestion in commit e24165537312
("dma-buf/sync_file: only enable fence signalling on poll()") to use a
single bit in the shared dma-fence and restores the sync_file-&gt;flags for
tracking the bits individually.

Reported-by: Gustavo Padovan &lt;gustavo.padovan@collabora.com&gt;
Fixes: f1e8c67123cf ("dma-buf/sw-sync: Use an rbtree to sort fences in the timeline")
Fixes: e9083420bbac ("drm: introduce sync objects (v4)")
Signed-off-by: Chris Wilson &lt;chris@chris-wilson.co.uk&gt;
Cc: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Cc: Sean Paul &lt;seanpaul@chromium.org&gt;
Cc: Gustavo Padovan &lt;gustavo@padovan.org&gt;
Cc: dri-devel@lists.freedesktop.org
Cc: &lt;drm-intel-fixes@lists.freedesktop.org&gt; # v4.13-rc1+
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.com&gt;
Link: http://patchwork.freedesktop.org/patch/msgid/20170728212951.7818-1-chris@chris-wilson.co.uk
(cherry picked from commit db1fc97ca0c0d3fdeeadf314d99a26188438940a)
</content>
</entry>
<entry>
<title>Merge branch 'drm-misc-next-fixes' into drm-misc-fixes</title>
<updated>2017-07-17T15:56:07+00:00</updated>
<author>
<name>Sean Paul</name>
<email>seanpaul@chromium.org</email>
</author>
<published>2017-07-17T15:43:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=ef434a0c2ce765ad33026375db7d23aebd5e9532'/>
<id>urn:sha1:ef434a0c2ce765ad33026375db7d23aebd5e9532</id>
<content type='text'>
Pick up

1ed134e6526b drm/vc4: Fix VBLANK handling in crtc-&gt;enable() path

From drm-misc-next-fixes, it was applied after the last pull request
was sent from that branch. We'll send it through drm-fixes instead.
</content>
</entry>
<entry>
<title>dma-buf/fence: Avoid use of uninitialised timestamp</title>
<updated>2017-07-14T19:09:55+00:00</updated>
<author>
<name>Chris Wilson</name>
<email>chris@chris-wilson.co.uk</email>
</author>
<published>2017-02-14T12:40:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=76250f2b743b72cb685cc51ac0cdabb32957180b'/>
<id>urn:sha1:76250f2b743b72cb685cc51ac0cdabb32957180b</id>
<content type='text'>
[  236.821534] WARNING: kmemcheck: Caught 64-bit read from uninitialized memory (ffff8802538683d0)
[  236.828642] 420000001e7f0000000000000000000000080000000000000000000000000000
[  236.839543]  i i i i u u u u i i i i i i i i u u u u u u u u u u u u u u u u
[  236.850420]                                  ^
[  236.854123] RIP: 0010:[&lt;ffffffff81396f07&gt;]  [&lt;ffffffff81396f07&gt;] fence_signal+0x17/0xd0
[  236.861313] RSP: 0018:ffff88024acd7ba0  EFLAGS: 00010282
[  236.865027] RAX: ffffffff812f6a90 RBX: ffff8802527ca800 RCX: ffff880252cb30e0
[  236.868801] RDX: ffff88024ac5d918 RSI: ffff880252f780e0 RDI: ffff880253868380
[  236.872579] RBP: ffff88024acd7bc0 R08: ffff88024acd7be0 R09: 0000000000000000
[  236.876407] R10: 0000000000000000 R11: 0000000000000000 R12: ffff880253868380
[  236.880185] R13: ffff8802538684d0 R14: ffff880253868380 R15: ffff88024cd48e00
[  236.883983] FS:  00007f1646d1a740(0000) GS:ffff88025d000000(0000) knlGS:0000000000000000
[  236.890959] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  236.894702] CR2: ffff880251360318 CR3: 000000024ad21000 CR4: 00000000001406f0
[  236.898481]  [&lt;ffffffff8130d1ad&gt;] i915_gem_request_retire+0x1cd/0x230
[  236.902439]  [&lt;ffffffff8130e2b3&gt;] i915_gem_request_alloc+0xa3/0x2f0
[  236.906435]  [&lt;ffffffff812fb1bd&gt;] i915_gem_do_execbuffer.isra.41+0xb6d/0x18b0
[  236.910434]  [&lt;ffffffff812fc265&gt;] i915_gem_execbuffer2+0x95/0x1e0
[  236.914390]  [&lt;ffffffff812ad625&gt;] drm_ioctl+0x1e5/0x460
[  236.918275]  [&lt;ffffffff8110d4cf&gt;] do_vfs_ioctl+0x8f/0x5c0
[  236.922168]  [&lt;ffffffff8110da3c&gt;] SyS_ioctl+0x3c/0x70
[  236.926090]  [&lt;ffffffff814b7a5f&gt;] entry_SYSCALL_64_fastpath+0x17/0x93
[  236.930045]  [&lt;ffffffffffffffff&gt;] 0xffffffffffffffff

We only set the timestamp before we mark the fence as signaled. It is
done before to avoid observers having a window in which they may see the
fence as complete but no timestamp. Having it does incur a potential for
the timestamp to be written twice, and even for it to be corrupted if
the u64 write is not atomic. Instead use a new bit to record the
presence of the timestamp, and teach the readers to wait until it is set
if the fence is complete. There still remains a race where the timestamp
for the signaled fence may be shown before the fence is reported as
signaled, but that's a pre-existing error.

Signed-off-by: Chris Wilson &lt;chris@chris-wilson.co.uk&gt;
Cc: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Cc: Gustavo Padovan &lt;gustavo@padovan.org&gt;
Cc: Daniel Vetter &lt;daniel.vetter@intel.com&gt;
Reported-by: Rafael Antognolli &lt;rafael.antognolli@intel.com&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.com&gt;
Link: http://patchwork.freedesktop.org/patch/msgid/20170214124001.1930-1-chris@chris-wilson.co.uk
</content>
</entry>
<entry>
<title>dma-buf/sync-file: Defer creation of sync_file-&gt;name</title>
<updated>2017-05-24T16:08:29+00:00</updated>
<author>
<name>Chris Wilson</name>
<email>chris@chris-wilson.co.uk</email>
</author>
<published>2017-05-16T11:10:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=71ebc9a3795818eab52e81bbcbdfae130ee35d9e'/>
<id>urn:sha1:71ebc9a3795818eab52e81bbcbdfae130ee35d9e</id>
<content type='text'>
Constructing the name takes the majority of the time for allocating a
sync_file to wrap a fence, and the name is very rarely used (only via
the sync_file status user interface). To reduce the impact on the common
path (that of creating sync_file to pass around), defer the construction
of the name until it is first used.

v2: Update kerneldoc (kbuild test robot)
v3: sync_debug.c was peeking at the name
v4: Comment upon the potential race between two users of
sync_file_get_name() and claim that such a race is below the level of
notice. However, to prevent any future nuisance, use a global spinlock
to serialize the assignment of the name.
v5: Completely avoid the read/write race by only storing the name passed
in from the user inside sync_file-&gt;user_name and passing in a buffer to
dynamically construct the name otherwise.

Signed-off-by: Chris Wilson &lt;chris@chris-wilson.co.uk&gt;
Cc: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Cc: Gustavo Padovan &lt;gustavo@padovan.org&gt;
Cc: Daniel Vetter &lt;daniel.vetter@ffwll.ch&gt;
Cc: David Herrmann &lt;dh.herrmann@gmail.com&gt;
Reviewed-by: Daniel Vetter &lt;daniel.vetter@ffwll.ch&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.com&gt;
Link: http://patchwork.freedesktop.org/patch/msgid/20170516111042.24719-1-chris@chris-wilson.co.uk
</content>
</entry>
<entry>
<title>sync_file: get rid of internal reference count.</title>
<updated>2017-04-18T13:27:38+00:00</updated>
<author>
<name>Dave Airlie</name>
<email>airlied@redhat.com</email>
</author>
<published>2017-04-13T01:41:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d8f2ebaac650dc35db3bf5cf10e8ee1115b455f8'/>
<id>urn:sha1:d8f2ebaac650dc35db3bf5cf10e8ee1115b455f8</id>
<content type='text'>
sync_file uses the reference count of the file, the internal
kref was never getting moved past 1.

We can reintroduce this if we decide we need it later.

[airlied: fix buildbot warnings]

Reviewed-by: Chris Wilson &lt;chris@chris-wilson.co.uk&gt;
Signed-off-by: Dave Airlie &lt;airlied@redhat.com&gt;
Acked-by: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Signed-off-by: Gustavo Padovan &lt;gustavo.padovan@collabora.com&gt;
Link: http://patchwork.freedesktop.org/patch/msgid/20170413014144.637-2-airlied@gmail.com
</content>
</entry>
<entry>
<title>dma-fence: Wrap querying the fence-&gt;status</title>
<updated>2017-01-09T14:36:58+00:00</updated>
<author>
<name>Chris Wilson</name>
<email>chris@chris-wilson.co.uk</email>
</author>
<published>2017-01-04T14:12:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d6c99f4bf093a58d3ab47caaec74b81f18bc4e3f'/>
<id>urn:sha1:d6c99f4bf093a58d3ab47caaec74b81f18bc4e3f</id>
<content type='text'>
The fence-&gt;status is an optional field that is only valid once the fence
has been signaled. (Driver may fill the fence-&gt;status with an error code
prior to calling dma_fence_signal().) Given the restriction upon its
validity, wrap querying of the fence-&gt;status into a helper
dma_fence_get_status().

Signed-off-by: Chris Wilson &lt;chris@chris-wilson.co.uk&gt;
Reviewed-by: Daniel Vetter &lt;daniel.vetter@ffwll.ch&gt;
Reviewed-by: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Signed-off-by: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Link: http://patchwork.freedesktop.org/patch/msgid/20170104141222.6992-2-chris@chris-wilson.co.uk
</content>
</entry>
<entry>
<title>dma-buf: Reorganize device dma access docs</title>
<updated>2016-12-13T11:39:51+00:00</updated>
<author>
<name>Daniel Vetter</name>
<email>daniel.vetter@ffwll.ch</email>
</author>
<published>2016-12-09T18:53:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=2904a8c1311f02896635fd35744262413a0b2726'/>
<id>urn:sha1:2904a8c1311f02896635fd35744262413a0b2726</id>
<content type='text'>
- Put the initial overview for dma-buf into dma-buf.rst.
- Put all the comments about detailed semantics into the right
  kernel-doc comment for functions or ops structure member.
- To allow that detail, switch the reworked kerneldoc to inline style
  for dma_buf_ops.
- Tie everything together into a much more streamlined overview
  comment, relying on the hyperlinks for all the details.
- Also sprinkle some links into the kerneldoc for dma_buf and
  dma_buf_attachment to tie it all together.

Cc: linux-doc@vger.kernel.org
Cc: Jonathan Corbet &lt;corbet@lwn.net&gt;
Cc: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Signed-off-by: Daniel Vetter &lt;daniel.vetter@intel.com&gt;
Signed-off-by: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Link: http://patchwork.freedesktop.org/patch/msgid/20161209185309.1682-4-daniel.vetter@ffwll.ch
</content>
</entry>
</feed>
