media: tegra: vi: replace devm_kzalloc with kzalloc in probe
Subsystems (4)
PATCH 1/1 media: tegra: vi: replace devm_kzalloc with kzalloc in probe
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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/media/tegra-video/vi.c +2 -1
@@ -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; }
Signature · 1 line
2.43.0
Quoted 4 lines · Dharanitharan R
Replace
devm_kzalloc()(line 1881) withkzalloc()integra_vi_probe()since memory must be freed manually in error paths. Freed viakfree()inrpm_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