All of lore.kernel.org
 help / color / mirror / Atom feed
From: Abel Vesa <abel.vesa@linaro.org>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	Amol Maheshwari <amahesh@qti.qualcomm.com>,
	Ekansh Gupta <ekangupt@qti.qualcomm.com>,
	Bharath Kumar <bkumar@qti.qualcomm.com>,
	Himateja Reddy <hmreddy@quicinc.com>,
	Anirudh Raghavendra <araghave@quicinc.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-arm-msm@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH v4 4/9] misc: fastrpc: Use fastrpc_map_put in fastrpc_map_create on fail
Date: Fri, 16 Sep 2022 18:40:57 +0300	[thread overview]
Message-ID: <20220916154102.1768088-5-abel.vesa@linaro.org> (raw)
In-Reply-To: <20220916154102.1768088-1-abel.vesa@linaro.org>

Move the kref_init right after the allocation so that we can use
fastrpc_map_put on any following error case.

Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/misc/fastrpc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 9e83743eaca1..0d9f1eb9a0ed 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -745,6 +745,8 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
 		return -ENOMEM;
 
 	INIT_LIST_HEAD(&map->node);
+	kref_init(&map->refcount);
+
 	map->fl = fl;
 	map->fd = fd;
 	map->buf = dma_buf_get(fd);
@@ -771,7 +773,6 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
 	map->size = len;
 	map->va = sg_virt(map->table->sgl);
 	map->len = len;
-	kref_init(&map->refcount);
 
 	if (attr & FASTRPC_ATTR_SECUREMAP) {
 		/*
@@ -801,7 +802,7 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
 attach_err:
 	dma_buf_put(map->buf);
 get_err:
-	kfree(map);
+	fastrpc_map_put(map);
 
 	return err;
 }
-- 
2.34.1


  parent reply	other threads:[~2022-09-16 15:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-16 15:40 [PATCH v4 0/9] misc: fastrpc: Add audiopd support Abel Vesa
2022-09-16 15:40 ` [PATCH v4 1/9] misc: fastrpc: Rename audio protection domain to root Abel Vesa
2022-09-16 15:40 ` [PATCH v4 2/9] misc: fastrpc: Add reserved mem support Abel Vesa
2022-09-16 15:40 ` [PATCH v4 3/9] misc: fastrpc: Add fastrpc_remote_heap_alloc Abel Vesa
2022-09-16 15:40 ` Abel Vesa [this message]
2022-09-16 15:40 ` [PATCH v4 5/9] misc: fastrpc: Rework fastrpc_req_munmap Abel Vesa
2022-09-16 15:40 ` [PATCH v4 6/9] misc: fastrpc: Add support for audiopd Abel Vesa
2022-09-16 15:41 ` [PATCH v4 7/9] misc: fastrpc: Safekeep mmaps on interrupted invoke Abel Vesa
2022-09-16 15:41 ` [PATCH v4 8/9] misc: fastrpc: Add mmap request assigning for static PD pool Abel Vesa
2022-09-16 15:41 ` [PATCH v4 9/9] misc: fastrpc: Add dma_mask to fastrpc_channel_ctx Abel Vesa

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=20220916154102.1768088-5-abel.vesa@linaro.org \
    --to=abel.vesa@linaro.org \
    --cc=amahesh@qti.qualcomm.com \
    --cc=araghave@quicinc.com \
    --cc=arnd@arndb.de \
    --cc=bkumar@qti.qualcomm.com \
    --cc=ekangupt@qti.qualcomm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hmreddy@quicinc.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.