All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mikko Perttunen" <mperttunen@nvidia.com>
Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org
Subject: Re: [PATCH 1/6] drm/tegra: Fix syncobj_in wait return value check
Date: Thu, 30 Jul 2026 04:58:31 +0000	[thread overview]
Message-ID: <20260730045831.BEAF31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260730-b4-host1x-syncobj-wait-v1-1-afa730410392@nvidia.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [Critical] If `host1x_fence_create()` fails, it returns an error pointer which is passed to `drm_syncobj_replace_fence()` due to a missing early return, causing a kernel crash when dereferenced.
- [High] The initial reference to the `dma_fence` allocated by `host1x_fence_create()` is leaked on the success path.
--

--- Patch [1]: [PATCH 1/6] drm/tegra: Fix syncobj_in wait return value check ---
commit 250614410b887862e5e7b49b5d80c8b53c8aa353
Author: Mikko Perttunen <mperttunen@nvidia.com>

drm/tegra: Fix syncobj_in wait return value check

dma_fence_wait_timeout() returns the remaining timeout in jiffies on
success, zero on timeout, and a negative error code if interrupted. The
return value was assigned to 'err' and checked as if it were an errno,
the opposite of the correct logic.

Fix the code to use a properly typed variable and check each condition
correctly.

Closes: https://lore.kernel.org/all/aJM_te551jUwnRv7@stanley.mountain/

> diff --git a/drivers/gpu/drm/tegra/submit.c b/drivers/gpu/drm/tegra/submit.c
> index e5841857c9378..5dad6dc4eb8c3 100644
> --- a/drivers/gpu/drm/tegra/submit.c
> +++ b/drivers/gpu/drm/tegra/submit.c

[ ... ]

[Severity: Critical]
This is a pre-existing issue, but I noticed a potential problem in
tegra_drm_ioctl_channel_submit() when handling syncobj_out:

	if (syncobj) {
		struct dma_fence *fence = host1x_fence_create(job->syncpt, job->syncpt_end, true);
		if (IS_ERR(fence)) {
			err = PTR_ERR(fence);
			SUBMIT_ERR(context, "failed to create postfence: %d", err);
		}

		drm_syncobj_replace_fence(syncobj, fence);
	}

If host1x_fence_create() fails, it returns an error pointer. Since there is
no early return or goto in the error handling block, the error pointer falls
through and is passed to drm_syncobj_replace_fence().

Looking at drm_syncobj_replace_fence() in drm_syncobj.c, it calls
dma_fence_get(fence) which checks 'if (fence)'. This would evaluate to true
for an error pointer, causing an attempt to increment the reference count on
the invalid pointer.

Should there be a 'goto put_job' or similar return path inside the
IS_ERR(fence) block to avoid this panic?

[Severity: High]
This is also a pre-existing issue, but in the same block of code, does
this leak the fence on the success path? 

host1x_fence_create() returns a new dma_fence with a reference count of 1.
drm_syncobj_replace_fence() then takes its own reference to the fence by
calling dma_fence_get().

However, I don't see a matching dma_fence_put(fence) in this function
after drm_syncobj_replace_fence(). Will the initial reference to the fence
be leaked for every successful ioctl call using syncobj_out?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260730-b4-host1x-syncobj-wait-v1-0-afa730410392@nvidia.com?part=1

  reply	other threads:[~2026-07-30  4:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30  4:44 [PATCH 0/6] Fixes and improvements to syncobj handling in TegraDRM submit path Mikko Perttunen
2026-07-30  4:44 ` [PATCH 1/6] drm/tegra: Fix syncobj_in wait return value check Mikko Perttunen
2026-07-30  4:58   ` sashiko-bot [this message]
2026-07-30  6:35     ` Mikko Perttunen
2026-07-30  4:44 ` [PATCH 2/6] drm/tegra: Don't pass an ERR_PTR to drm_syncobj_replace_fence() Mikko Perttunen
2026-07-30  4:44 ` [PATCH 3/6] drm/tegra: Drop reference on postfence Mikko Perttunen
2026-07-30  4:57   ` sashiko-bot
2026-07-30  6:37     ` Mikko Perttunen
2026-07-30  4:44 ` [PATCH 4/6] drm/tegra: Remove unused includes from submit.c Mikko Perttunen
2026-07-30  4:44 ` [PATCH 5/6] gpu: host1x: Add host1x_fence_extract() Mikko Perttunen
2026-07-30  4:44 ` [PATCH 6/6] drm/tegra: Wait for syncpoint syncobj_in fences in hardware Mikko Perttunen

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=20260730045831.BEAF31F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=media-ci@linuxtv.org \
    --cc=mperttunen@nvidia.com \
    --cc=sashiko-reviews@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.