drivers/staging/media/tegra-video/vi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Replace devm_kzalloc() (line 1881) with kzalloc() in tegra_vi_probe()
since memory must be freed manually in error paths. Freed via kfree() in
rpm_disable, as recommended in the file comment (line 1204).
Signed-off-by: Dharanitharan R <dharanitharan725@gmail.com>
---
drivers/staging/media/tegra-video/vi.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c
index c9276ff76157..73127ea6ee49 100644
--- a/drivers/staging/media/tegra-video/vi.c
+++ b/drivers/staging/media/tegra-video/vi.c
@@ -1878,7 +1878,7 @@ static int tegra_vi_probe(struct platform_device *pdev)
struct tegra_vi *vi;
int ret;
- vi = devm_kzalloc(&pdev->dev, sizeof(*vi), GFP_KERNEL);
+ vi = kzalloc(sizeof(*vi), GFP_KERNEL);
if (!vi)
return -ENOMEM;
@@ -1941,6 +1941,7 @@ static int tegra_vi_probe(struct platform_device *pdev)
if (vi->ops->vi_enable)
vi->ops->vi_enable(vi, false);
pm_runtime_disable(&pdev->dev);
+ kfree(vi);
return ret;
}
--
2.43.0
On Wed, Nov 26, 2025 at 06:52:42AM +0000, Dharanitharan R wrote:
> Replace devm_kzalloc() (line 1881) with kzalloc() in tegra_vi_probe()
> since memory must be freed manually in error paths. Freed via kfree() in
> rpm_disable, as recommended in the file comment (line 1204).
>
drivers/staging/media/tegra-video/vi.c
1197 static int tegra_vi_channel_alloc(struct tegra_vi *vi, unsigned int port_num,
1198 struct device_node *node, unsigned int lanes)
1199 {
1200 struct tegra_vi_channel *chan;
1201 unsigned int i;
1202
1203 /*
1204 * Do not use devm_kzalloc as memory is freed immediately
1205 * when device instance is unbound but application might still
1206 * be holding the device node open. Channel memory allocated
1207 * with kzalloc is freed during video device release callback.
1208 */
1209 chan = kzalloc(sizeof(*chan), GFP_KERNEL);
1210 if (!chan)
1211 return -ENOMEM;
1212
The comment is specific to "chan".
Your patch introduces a number of memory leaks and it's not
correct.
regards,
dan carpenter
© 2016 - 2025 Red Hat, Inc.