From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1F5822D7A9; Sun, 1 Mar 2026 01:15:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772327730; cv=none; b=loPkgIKu8qRYSCCSCEiANfVenfkk8GD1LOnwPx8jE/DHzqddiagUnkUwt14XoxXkqsKFZjkfuEh4Q11S0PEwI+USTZQ9Tn6iSicQPZbRvpgUHN4sLm4hC/CNoQbOpWL+rGdvSXON/1Ep3m9yGn5nAhxwXed8YjbbewJmEXyTfx4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772327730; c=relaxed/simple; bh=TIxQSLnpH7VGK9ejWjNF29LPJEVPfLMt6+Mb6Wq8iOE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=mP8V4b9o4ub+65geONwtKwdhEJ4AV9//j63sin+c8Z6EVYunCpQUB8F8Jf0y8uilh8zTP0HzUXQL1Nph59458lK0vJnj//mxff3yUUZRox+2yK0X7gt0JcOCftvuFi+jhubxToaOlMgWYTeNBYlvLskC8L22NcL97+1RrY29xOQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uXrXthYN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uXrXthYN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2736C19421; Sun, 1 Mar 2026 01:15:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772327729; bh=TIxQSLnpH7VGK9ejWjNF29LPJEVPfLMt6+Mb6Wq8iOE=; h=From:To:Cc:Subject:Date:From; b=uXrXthYNv6HOv8JAxJN5xi/D8rL/aUtD7CeQeiU9ez8HcARWU63tXQV3sIuI+e5So YGG7QNf+uz+6djtAeGAqZFV6S+Ax/NrcEOXa0ofSVd5s1dns3hgPpz+M9NlSC6+Ceh W91D0IwUUAtQUVztP7mOTNOQm1Ob6SnlUNp+uHgphsCjYkJnIU5vdvpGU3UoGIdNsU iESqetp4KuiVuIIBCzx4SIw4PVF7xUOAfmIz7BSvI5G6Ovz6skOgCWeMl7VF1AIXZi bpOXpDAVnXieDL1ZMmfhsiIjuBg18nEvh+b78uEqWa8xxwCbw2LchTXw9OMTXilBAZ 3/bBRhguAd3gw== From: Sasha Levin To: stable@vger.kernel.org, zilin@seu.edu.cn Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, linux-staging@lists.linux.dev Subject: FAILED: Patch "media: tegra-video: Fix memory leak in __tegra_channel_try_format()" failed to apply to 6.18-stable tree Date: Sat, 28 Feb 2026 20:15:27 -0500 Message-ID: <20260301011527.1668754-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Hint: ignore X-stable: review Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.18-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . Thanks, Sasha ------------------ original commit in Linus's tree ------------------ >From 43e5302d22334f1183dec3e0d5d8007eefe2817c Mon Sep 17 00:00:00 2001 From: Zilin Guan Date: Fri, 14 Nov 2025 09:12:57 +0000 Subject: [PATCH] media: tegra-video: Fix memory leak in __tegra_channel_try_format() The state object allocated by __v4l2_subdev_state_alloc() must be freed with __v4l2_subdev_state_free() when it is no longer needed. In __tegra_channel_try_format(), two error paths return directly after v4l2_subdev_call() fails, without freeing the allocated 'sd_state' object. This violates the requirement and causes a memory leak. Fix this by introducing a cleanup label and using goto statements in the error paths to ensure that __v4l2_subdev_state_free() is always called before the function returns. Fixes: 56f64b82356b7 ("media: tegra-video: Use zero crop settings if subdev has no get_selection") Fixes: 1ebaeb09830f3 ("media: tegra-video: Add support for external sensor capture") Cc: stable@vger.kernel.org Signed-off-by: Zilin Guan Signed-off-by: Hans Verkuil --- drivers/staging/media/tegra-video/vi.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index c9276ff76157f..14b327afe045e 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -438,7 +438,7 @@ static int __tegra_channel_try_format(struct tegra_vi_channel *chan, .target = V4L2_SEL_TGT_CROP_BOUNDS, }; struct v4l2_rect *try_crop; - int ret; + int ret = 0; subdev = tegra_channel_get_remote_source_subdev(chan); if (!subdev) @@ -482,8 +482,10 @@ static int __tegra_channel_try_format(struct tegra_vi_channel *chan, } else { ret = v4l2_subdev_call(subdev, pad, get_selection, NULL, &sdsel); - if (ret) - return -EINVAL; + if (ret) { + ret = -EINVAL; + goto out_free; + } try_crop->width = sdsel.r.width; try_crop->height = sdsel.r.height; @@ -495,14 +497,15 @@ static int __tegra_channel_try_format(struct tegra_vi_channel *chan, ret = v4l2_subdev_call(subdev, pad, set_fmt, sd_state, &fmt); if (ret < 0) - return ret; + goto out_free; v4l2_fill_pix_format(pix, &fmt.format); chan->vi->ops->vi_fmt_align(pix, fmtinfo->bpp); +out_free: __v4l2_subdev_state_free(sd_state); - return 0; + return ret; } static int tegra_channel_try_format(struct file *file, void *fh, -- 2.51.0