diff options
author | Abel Vesa <[email protected]> | 2022-11-25 07:14:00 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <[email protected]> | 2022-11-25 18:45:33 +0100 |
commit | 334f1a1cbe032d85fd58e771629e3a3b373b96d5 (patch) | |
tree | b89425f88e72705774d26bed93e7ee8666537874 | |
parent | 6f18c7e845346f365e08613fdc47a60fc201aedb (diff) |
misc: fastrpc: Use fastrpc_map_put in fastrpc_map_create on fail
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 <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r-- | drivers/misc/fastrpc.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 8b43fe5207fb..332626df5d39 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -735,6 +735,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); @@ -761,7 +763,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) { /* @@ -791,7 +792,7 @@ map_err: attach_err: dma_buf_put(map->buf); get_err: - kfree(map); + fastrpc_map_put(map); return err; } |