From: Dan Carpenter <dan.carpenter@linaro.org>
To: Dharanitharan R <dharanitharan725@gmail.com>
Cc: thierry.reding@gmail.com, jonathanh@nvidia.com,
skomatineni@nvidia.com, luca.ceresoli@bootlin.com,
mchehab@kernel.org, gregkh@linuxfoundation.org,
linux-media@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] media: tegra: vi: replace devm_kzalloc with kzalloc in probe
Date: Wed, 26 Nov 2025 11:58:52 +0300 [thread overview]
Message-ID: <aSbBTPXdk2wXQm7R@stanley.mountain> (raw)
In-Reply-To: <20251126065242.12186-1-dharanitharan725@gmail.com>
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
prev parent reply other threads:[~2025-11-26 8:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 6:52 [PATCH v1] media: tegra: vi: replace devm_kzalloc with kzalloc in probe Dharanitharan R
2025-11-26 8:58 ` Dan Carpenter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aSbBTPXdk2wXQm7R@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=dharanitharan725@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=linux-tegra@vger.kernel.org \
--cc=luca.ceresoli@bootlin.com \
--cc=mchehab@kernel.org \
--cc=skomatineni@nvidia.com \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).