diff options
author | Abel Vesa <abel.vesa@linaro.org> | 2022-09-01 18:26:49 +0300 |
---|---|---|
committer | Abel Vesa <abel.vesa@linaro.org> | 2022-09-06 14:13:43 +0300 |
commit | 06778c898ea31bad396397c6796b3f4632f12c98 (patch) | |
tree | 2ba7b932af572abeb692cda42d1f64f978db14cf | |
parent | 90cdb95ffff28791f0910d257af236186713a3bc (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 <abel.vesa@linaro.org>
-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 6730aa324e10..5eececd9b6bd 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 @@ map_err: attach_err: dma_buf_put(map->buf); get_err: - kfree(map); + fastrpc_map_put(map); return err; } |