Re: [PATCH v1] media: tegra: vi: replace devm_kzalloc with kzalloc in probe
From: Dan Carpenter
Date: Wed Nov 26 2025 - 03:58:59 EST
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