Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 23 additions & 18 deletions drivers/misc/fastrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,30 @@ static void fastrpc_channel_ctx_put(struct fastrpc_channel_ctx *cctx)
kref_put(&cctx->refcount, fastrpc_channel_ctx_free);
}

static void fastrpc_context_put(struct fastrpc_invoke_ctx *ctx);

static void fastrpc_user_free(struct kref *ref)
{
struct fastrpc_user *fl = container_of(ref, struct fastrpc_user, refcount);
struct fastrpc_invoke_ctx *ctx, *n;
struct fastrpc_map *map, *m;
struct fastrpc_buf *buf, *b;

if (fl->init_mem)
fastrpc_buf_free(fl->init_mem);

list_for_each_entry_safe(ctx, n, &fl->pending, node) {
list_del(&ctx->node);
fastrpc_context_put(ctx);
}

list_for_each_entry_safe(map, m, &fl->maps, node)
fastrpc_map_put(map);

list_for_each_entry_safe(buf, b, &fl->mmaps, node) {
list_del(&buf->node);
fastrpc_buf_free(buf);
}

fastrpc_channel_ctx_put(fl->cctx);
mutex_destroy(&fl->mutex);
Expand Down Expand Up @@ -1655,9 +1676,6 @@ static int fastrpc_device_release(struct inode *inode, struct file *file)
{
struct fastrpc_user *fl = (struct fastrpc_user *)file->private_data;
struct fastrpc_channel_ctx *cctx = fl->cctx;
struct fastrpc_invoke_ctx *ctx, *n;
struct fastrpc_map *map, *m;
struct fastrpc_buf *buf, *b;
unsigned long flags;

fastrpc_release_current_dsp_process(fl);
Expand All @@ -1666,23 +1684,10 @@ static int fastrpc_device_release(struct inode *inode, struct file *file)
list_del(&fl->user);
spin_unlock_irqrestore(&cctx->lock, flags);

fastrpc_buf_free(fl->init_mem);

list_for_each_entry_safe(ctx, n, &fl->pending, node) {
list_del(&ctx->node);
fastrpc_context_put(ctx);
}

list_for_each_entry_safe(map, m, &fl->maps, node)
fastrpc_map_put(map);

list_for_each_entry_safe(buf, b, &fl->mmaps, node) {
list_del(&buf->node);
fastrpc_buf_free(buf);
}

fastrpc_session_free(cctx, fl->sctx);

file->private_data = NULL;

/* Release the reference taken in fastrpc_device_open */
fastrpc_user_put(fl);

Expand Down