mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Beleswar Padhi <b-padhi@ti.com>
To: <andersson@kernel.org>, <mathieu.poirier@linaro.org>
Cc: <afd@ti.com>, <hnagalla@ti.com>, <u-kumar1@ti.com>,
	<jan.kiszka@siemens.com>, <christophe.jaillet@wanadoo.fr>,
	<b-padhi@ti.com>, <linux-remoteproc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH 2/5] remoteproc: k3-r5: Use devm_kcalloc() helper
Date: Wed, 4 Dec 2024 16:41:27 +0530	[thread overview]
Message-ID: <20241204111130.2218497-3-b-padhi@ti.com> (raw)
In-Reply-To: <20241204111130.2218497-1-b-padhi@ti.com>

Use a device lifecycle managed action to free memory. This helps prevent
mistakes like freeing out of order in cleanup functions and forgetting
to free on error paths.

Signed-off-by: Beleswar Padhi <b-padhi@ti.com>
---
 drivers/remoteproc/ti_k3_r5_remoteproc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c
index d51f88a5abc1..0753a5c35c7e 100644
--- a/drivers/remoteproc/ti_k3_r5_remoteproc.c
+++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c
@@ -997,7 +997,7 @@ static int k3_r5_reserved_mem_init(struct k3_r5_rproc *kproc)
 		return ret;
 
 	num_rmems--;
-	kproc->rmem = kcalloc(num_rmems, sizeof(*kproc->rmem), GFP_KERNEL);
+	kproc->rmem = devm_kcalloc(dev, num_rmems, sizeof(*kproc->rmem), GFP_KERNEL);
 	if (!kproc->rmem)
 		return -ENOMEM;
 
@@ -1049,7 +1049,6 @@ static int k3_r5_reserved_mem_init(struct k3_r5_rproc *kproc)
 unmap_rmem:
 	for (i--; i >= 0; i--)
 		iounmap(kproc->rmem[i].cpu_addr);
-	kfree(kproc->rmem);
 	return ret;
 }
 
@@ -1059,7 +1058,6 @@ static void k3_r5_reserved_mem_exit(struct k3_r5_rproc *kproc)
 
 	for (i = 0; i < kproc->num_rmems; i++)
 		iounmap(kproc->rmem[i].cpu_addr);
-	kfree(kproc->rmem);
 }
 
 /*
-- 
2.34.1


  parent reply	other threads:[~2024-12-04 11:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-04 11:11 [PATCH 0/5] Use Device Lifecycle managed functions in TI R5 Remoteproc Beleswar Padhi
2024-12-04 11:11 ` [PATCH 1/5] remoteproc: k3-r5: Add devm action to release reserved memory Beleswar Padhi
2024-12-04 11:11 ` Beleswar Padhi [this message]
2024-12-04 11:11 ` [PATCH 3/5] remoteproc: k3-r5: Add devm action to release tsp Beleswar Padhi
2024-12-17 16:00   ` Andrew Davis
2024-12-18  8:22     ` Beleswar Prasad Padhi
2024-12-04 11:11 ` [PATCH 4/5] remoteproc: k3-r5: Use devm_ioremap_wc() helper Beleswar Padhi
2024-12-17 16:03   ` Andrew Davis
2024-12-18  8:23     ` Beleswar Prasad Padhi
2024-12-04 11:11 ` [PATCH 5/5] remoteproc: k3-r5: Use devm_rproc_add() helper Beleswar Padhi
2024-12-16 16:55 ` [PATCH 0/5] Use Device Lifecycle managed functions in TI R5 Remoteproc Mathieu Poirier

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=20241204111130.2218497-3-b-padhi@ti.com \
    --to=b-padhi@ti.com \
    --cc=afd@ti.com \
    --cc=andersson@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=hnagalla@ti.com \
    --cc=jan.kiszka@siemens.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=u-kumar1@ti.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

all inboxes | Powered by JetHome®