* [PATCH] staging: media: tegra-video: fix syncpoint leak in tegra20 channel init
@ 2026-07-26 10:04 Cong Nguyen
2026-07-27 5:13 ` Mikko Perttunen
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Cong Nguyen @ 2026-07-26 10:04 UTC (permalink / raw)
To: Thierry Reding
Cc: Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
Mauro Carvalho Chehab, Greg Kroah-Hartman, Svyatoslav Ryhel,
linux-media, linux-tegra, linux-staging, linux-kernel,
Cong Nguyen
tegra20_channel_host1x_syncpt_init() requests two host1x syncpoints. It
stored the first one (mw ack) into chan->mw_ack_sp[0] and only then
requested the second one (frame start). If the second request failed the
function returned without releasing the first syncpoint, leaking it: the
caller tegra_channel_init() bails out with a bare "return ret" on a
syncpt init failure and does not run its free_syncpts error path (that
path only covers failures after syncpoint init has fully succeeded), and
the channel is subsequently torn down via the kfree()-only path, so
nothing ever releases the orphaned syncpoint.
Release the already-acquired syncpoint on the error path, and only
publish the syncpoints into the channel once both have been successfully
requested, so chan->mw_ack_sp[0] never holds a released handle. This
matches the handling in tegra210_channel_host1x_syncpt_init().
Fixes: 0e2c4117c351 ("staging: media: tegra-video: add CSI support for Tegra20 and Tegra30")
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
---
drivers/staging/media/tegra-video/tegra20.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/media/tegra-video/tegra20.c b/drivers/staging/media/tegra-video/tegra20.c
index e513e6ccb776..f8acb6834a0b 100644
--- a/drivers/staging/media/tegra-video/tegra20.c
+++ b/drivers/staging/media/tegra-video/tegra20.c
@@ -429,12 +429,13 @@ static int tegra20_channel_host1x_syncpt_init(struct tegra_vi_channel *chan)
if (!out_sp)
return dev_err_probe(vi->dev, -EBUSY, "failed to request mw ack syncpoint\n");
- chan->mw_ack_sp[0] = out_sp;
-
fs_sp = host1x_syncpt_request(&vi->client, HOST1X_SYNCPT_CLIENT_MANAGED);
- if (!fs_sp)
+ if (!fs_sp) {
+ host1x_syncpt_put(out_sp);
return dev_err_probe(vi->dev, -EBUSY, "failed to request frame start syncpoint\n");
+ }
+ chan->mw_ack_sp[0] = out_sp;
chan->frame_start_sp[0] = fs_sp;
return 0;
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] staging: media: tegra-video: fix syncpoint leak in tegra20 channel init
2026-07-26 10:04 [PATCH] staging: media: tegra-video: fix syncpoint leak in tegra20 channel init Cong Nguyen
@ 2026-07-27 5:13 ` Mikko Perttunen
2026-07-27 8:10 ` Svyatoslav Ryhel
2026-07-27 8:30 ` Luca Ceresoli
2 siblings, 0 replies; 4+ messages in thread
From: Mikko Perttunen @ 2026-07-27 5:13 UTC (permalink / raw)
To: Thierry Reding, Cong Nguyen
Cc: Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
Mauro Carvalho Chehab, Greg Kroah-Hartman, Svyatoslav Ryhel,
linux-media, linux-tegra, linux-staging, linux-kernel,
Cong Nguyen
On Sunday, July 26, 2026 7:04 PM Cong Nguyen wrote:
> tegra20_channel_host1x_syncpt_init() requests two host1x syncpoints. It
> stored the first one (mw ack) into chan->mw_ack_sp[0] and only then
> requested the second one (frame start). If the second request failed the
> function returned without releasing the first syncpoint, leaking it: the
> caller tegra_channel_init() bails out with a bare "return ret" on a
> syncpt init failure and does not run its free_syncpts error path (that
> path only covers failures after syncpoint init has fully succeeded), and
> the channel is subsequently torn down via the kfree()-only path, so
> nothing ever releases the orphaned syncpoint.
>
> Release the already-acquired syncpoint on the error path, and only
> publish the syncpoints into the channel once both have been successfully
> requested, so chan->mw_ack_sp[0] never holds a released handle. This
> matches the handling in tegra210_channel_host1x_syncpt_init().
>
> Fixes: 0e2c4117c351 ("staging: media: tegra-video: add CSI support for Tegra20 and Tegra30")
> Signed-off-by: Cong Nguyen <congnt264@gmail.com>
> ---
> drivers/staging/media/tegra-video/tegra20.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/media/tegra-video/tegra20.c b/drivers/staging/media/tegra-video/tegra20.c
> index e513e6ccb776..f8acb6834a0b 100644
> --- a/drivers/staging/media/tegra-video/tegra20.c
> +++ b/drivers/staging/media/tegra-video/tegra20.c
> @@ -429,12 +429,13 @@ static int tegra20_channel_host1x_syncpt_init(struct tegra_vi_channel *chan)
> if (!out_sp)
> return dev_err_probe(vi->dev, -EBUSY, "failed to request mw ack syncpoint\n");
>
> - chan->mw_ack_sp[0] = out_sp;
> -
> fs_sp = host1x_syncpt_request(&vi->client, HOST1X_SYNCPT_CLIENT_MANAGED);
> - if (!fs_sp)
> + if (!fs_sp) {
> + host1x_syncpt_put(out_sp);
> return dev_err_probe(vi->dev, -EBUSY, "failed to request frame start syncpoint\n");
> + }
>
> + chan->mw_ack_sp[0] = out_sp;
> chan->frame_start_sp[0] = fs_sp;
>
> return 0;
> --
> 2.25.1
>
>
Thanks!
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] staging: media: tegra-video: fix syncpoint leak in tegra20 channel init
2026-07-26 10:04 [PATCH] staging: media: tegra-video: fix syncpoint leak in tegra20 channel init Cong Nguyen
2026-07-27 5:13 ` Mikko Perttunen
@ 2026-07-27 8:10 ` Svyatoslav Ryhel
2026-07-27 8:30 ` Luca Ceresoli
2 siblings, 0 replies; 4+ messages in thread
From: Svyatoslav Ryhel @ 2026-07-27 8:10 UTC (permalink / raw)
To: Cong Nguyen
Cc: Thierry Reding, Jonathan Hunter, Sowjanya Komatineni,
Luca Ceresoli, Mauro Carvalho Chehab, Greg Kroah-Hartman,
linux-media, linux-tegra, linux-staging, linux-kernel
нд, 26 лип. 2026 р. о 13:04 Cong Nguyen <congnt264@gmail.com> пише:
>
> tegra20_channel_host1x_syncpt_init() requests two host1x syncpoints. It
> stored the first one (mw ack) into chan->mw_ack_sp[0] and only then
> requested the second one (frame start). If the second request failed the
> function returned without releasing the first syncpoint, leaking it: the
> caller tegra_channel_init() bails out with a bare "return ret" on a
> syncpt init failure and does not run its free_syncpts error path (that
> path only covers failures after syncpoint init has fully succeeded), and
> the channel is subsequently torn down via the kfree()-only path, so
> nothing ever releases the orphaned syncpoint.
>
> Release the already-acquired syncpoint on the error path, and only
> publish the syncpoints into the channel once both have been successfully
> requested, so chan->mw_ack_sp[0] never holds a released handle. This
> matches the handling in tegra210_channel_host1x_syncpt_init().
>
> Fixes: 0e2c4117c351 ("staging: media: tegra-video: add CSI support for Tegra20 and Tegra30")
> Signed-off-by: Cong Nguyen <congnt264@gmail.com>
> ---
> drivers/staging/media/tegra-video/tegra20.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
Very nice, thank you!
Reviewed-by: Svyatoslav Ryhel <clamor95@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] staging: media: tegra-video: fix syncpoint leak in tegra20 channel init
2026-07-26 10:04 [PATCH] staging: media: tegra-video: fix syncpoint leak in tegra20 channel init Cong Nguyen
2026-07-27 5:13 ` Mikko Perttunen
2026-07-27 8:10 ` Svyatoslav Ryhel
@ 2026-07-27 8:30 ` Luca Ceresoli
2 siblings, 0 replies; 4+ messages in thread
From: Luca Ceresoli @ 2026-07-27 8:30 UTC (permalink / raw)
To: Cong Nguyen, Thierry Reding
Cc: Jonathan Hunter, Sowjanya Komatineni, Luca Ceresoli,
Mauro Carvalho Chehab, Greg Kroah-Hartman, Svyatoslav Ryhel,
linux-media, linux-tegra, linux-staging, linux-kernel
On Sun Jul 26, 2026 at 12:04 PM CEST, Cong Nguyen wrote:
> tegra20_channel_host1x_syncpt_init() requests two host1x syncpoints. It
> stored the first one (mw ack) into chan->mw_ack_sp[0] and only then
> requested the second one (frame start). If the second request failed the
> function returned without releasing the first syncpoint, leaking it: the
> caller tegra_channel_init() bails out with a bare "return ret" on a
> syncpt init failure and does not run its free_syncpts error path (that
> path only covers failures after syncpoint init has fully succeeded), and
> the channel is subsequently torn down via the kfree()-only path, so
> nothing ever releases the orphaned syncpoint.
>
> Release the already-acquired syncpoint on the error path, and only
> publish the syncpoints into the channel once both have been successfully
> requested, so chan->mw_ack_sp[0] never holds a released handle. This
> matches the handling in tegra210_channel_host1x_syncpt_init().
>
> Fixes: 0e2c4117c351 ("staging: media: tegra-video: add CSI support for Tegra20 and Tegra30")
> Signed-off-by: Cong Nguyen <congnt264@gmail.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-27 8:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-26 10:04 [PATCH] staging: media: tegra-video: fix syncpoint leak in tegra20 channel init Cong Nguyen
2026-07-27 5:13 ` Mikko Perttunen
2026-07-27 8:10 ` Svyatoslav Ryhel
2026-07-27 8:30 ` Luca Ceresoli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).