mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
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> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20221125071405.148786-6-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
6f18c7e845
commit
334f1a1cbe
|
|
@ -735,6 +735,8 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
INIT_LIST_HEAD(&map->node);
|
INIT_LIST_HEAD(&map->node);
|
||||||
|
kref_init(&map->refcount);
|
||||||
|
|
||||||
map->fl = fl;
|
map->fl = fl;
|
||||||
map->fd = fd;
|
map->fd = fd;
|
||||||
map->buf = dma_buf_get(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->size = len;
|
||||||
map->va = sg_virt(map->table->sgl);
|
map->va = sg_virt(map->table->sgl);
|
||||||
map->len = len;
|
map->len = len;
|
||||||
kref_init(&map->refcount);
|
|
||||||
|
|
||||||
if (attr & FASTRPC_ATTR_SECUREMAP) {
|
if (attr & FASTRPC_ATTR_SECUREMAP) {
|
||||||
/*
|
/*
|
||||||
|
|
@ -791,7 +792,7 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
|
||||||
attach_err:
|
attach_err:
|
||||||
dma_buf_put(map->buf);
|
dma_buf_put(map->buf);
|
||||||
get_err:
|
get_err:
|
||||||
kfree(map);
|
fastrpc_map_put(map);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user