linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] media: tegra: vi: replace devm_kzalloc with kzalloc in probe
@ 2025-11-26  6:52 Dharanitharan R
  2025-11-26  8:58 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Dharanitharan R @ 2025-11-26  6:52 UTC (permalink / raw)
  To: thierry.reding
  Cc: jonathanh, skomatineni, luca.ceresoli, mchehab, gregkh,
	linux-media, linux-tegra, linux-staging, linux-kernel,
	Dharanitharan R

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] media: tegra: vi: replace devm_kzalloc with kzalloc in probe
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2025-11-26  8:58 UTC (permalink / raw)
  To: Dharanitharan R
  Cc: thierry.reding, jonathanh, skomatineni, luca.ceresoli, mchehab,
	gregkh, linux-media, linux-tegra, linux-staging, linux-kernel

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-26  8:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).