From: "Christian König" <christian.koenig@amd.com>
To: Dan Carpenter <error27@gmail.com>
Cc: oe-kbuild@lists.linux.dev, Jason Gunthorpe <jgg@nvidia.com>,
lkp@intel.com, oe-kbuild-all@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: drivers/dma-buf/st-dma-fence-chain.c:207 test_find_seqno() warn: passing freed memory 'fence' (line 195)
Date: Fri, 11 Sep 2026 18:26:59 +0200 [thread overview]
Message-ID: <53a024f3-5e2e-4cb0-9fce-0d0ae6584e6c@amd.com> (raw)
In-Reply-To: <aqPyeNLCsy-k0DIz@stanley.mountain>
On 9/11/26 14:22, Dan Carpenter wrote:
> On Fri, Sep 11, 2026 at 09:49:54AM +0200, Christian König wrote:
>> Hi Dan,
>>
>> I just double check and this one and the other "warn: passing freed memory 'fence'" look like a false positive to me.
>>
>> Any idea why smatch things that the memory is already freed in the test case?
>
> dma_fence_put() can free the fence if we drop the last reference.
> Or imagine that we aren't holding the last reference and a different
> thread is holding it and they could call dma_fence_put() which is
> also a use after free.
>
> Incrementing then decrementing then incrementing the reference
> count doesn't make any sense. We are relying on something else
> to hold the reference. If we can rely on that, then we don't
> need to increment and decrement the reference count for certain
> basically random places.
Ok, well then that indeed seems to be a false positive from smatch.
The pattern is this:
get(fence);
make_fence_point_to_something_different(&fence);
put(fence);
The make_fence_point_to_something_different() function consumes the original fence reference and returns a new one. So the get/put dance is completely correct. (Well it indeed doesn't make much sense, normally you would do something with the returned reference before calling put. But that here is just to test the make_fence_point_to_something_different() function).
Regards,
Christian.
>
> regards,
> dan carpenter
>
prev parent reply other threads:[~2026-09-11 16:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 14:15 Dan Carpenter
2026-09-11 7:49 ` Christian König
2026-09-11 12:22 ` Dan Carpenter
2026-09-11 16:26 ` Christian König [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53a024f3-5e2e-4cb0-9fce-0d0ae6584e6c@amd.com \
--to=christian.koenig@amd.com \
--cc=error27@gmail.com \
--cc=jgg@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=oe-kbuild@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®