@@ -329,8 +329,6 @@ struct fastrpc_user {
329329 spinlock_t lock ;
330330 /* lock for allocations */
331331 struct mutex mutex ;
332- /* Reference count */
333- struct kref refcount ;
334332};
335333
336334static void fastrpc_free_map (struct kref * ref )
@@ -502,36 +500,15 @@ static void fastrpc_channel_ctx_put(struct fastrpc_channel_ctx *cctx)
502500 kref_put (& cctx -> refcount , fastrpc_channel_ctx_free );
503501}
504502
505- static void fastrpc_user_free (struct kref * ref )
506- {
507- struct fastrpc_user * fl = container_of (ref , struct fastrpc_user , refcount );
508-
509- fastrpc_channel_ctx_put (fl -> cctx );
510- mutex_destroy (& fl -> mutex );
511- kfree (fl );
512- }
513-
514- static void fastrpc_user_get (struct fastrpc_user * fl )
515- {
516- kref_get (& fl -> refcount );
517- }
518-
519- static void fastrpc_user_put (struct fastrpc_user * fl )
520- {
521- kref_put (& fl -> refcount , fastrpc_user_free );
522- }
523-
524503static void fastrpc_context_free (struct kref * ref )
525504{
526505 struct fastrpc_invoke_ctx * ctx ;
527506 struct fastrpc_channel_ctx * cctx ;
528- struct fastrpc_user * fl ;
529507 unsigned long flags ;
530508 int i ;
531509
532510 ctx = container_of (ref , struct fastrpc_invoke_ctx , refcount );
533511 cctx = ctx -> cctx ;
534- fl = ctx -> fl ;
535512
536513 for (i = 0 ; i < ctx -> nbufs ; i ++ )
537514 fastrpc_map_put (ctx -> maps [i ]);
@@ -546,8 +523,6 @@ static void fastrpc_context_free(struct kref *ref)
546523 kfree (ctx -> olaps );
547524 kfree (ctx );
548525
549- /* Release the reference taken in fastrpc_context_alloc() */
550- fastrpc_user_put (fl );
551526 fastrpc_channel_ctx_put (cctx );
552527}
553528
@@ -657,8 +632,6 @@ static struct fastrpc_invoke_ctx *fastrpc_context_alloc(
657632
658633 /* Released in fastrpc_context_put() */
659634 fastrpc_channel_ctx_get (cctx );
660- /* Take a reference to user, released in fastrpc_context_free() */
661- fastrpc_user_get (user );
662635
663636 ctx -> sc = sc ;
664637 ctx -> retval = -1 ;
@@ -689,7 +662,6 @@ static struct fastrpc_invoke_ctx *fastrpc_context_alloc(
689662 spin_lock (& user -> lock );
690663 list_del (& ctx -> node );
691664 spin_unlock (& user -> lock );
692- fastrpc_user_put (user );
693665 fastrpc_channel_ctx_put (cctx );
694666 kfree (ctx -> maps );
695667 kfree (ctx -> olaps );
@@ -1682,9 +1654,11 @@ static int fastrpc_device_release(struct inode *inode, struct file *file)
16821654 }
16831655
16841656 fastrpc_session_free (cctx , fl -> sctx );
1657+ fastrpc_channel_ctx_put (cctx );
1658+
1659+ mutex_destroy (& fl -> mutex );
1660+ kfree (fl );
16851661 file -> private_data = NULL ;
1686- /* Release the reference taken in fastrpc_device_open */
1687- fastrpc_user_put (fl );
16881662
16891663 return 0 ;
16901664}
@@ -1728,7 +1702,6 @@ static int fastrpc_device_open(struct inode *inode, struct file *filp)
17281702 spin_lock_irqsave (& cctx -> lock , flags );
17291703 list_add_tail (& fl -> user , & cctx -> users );
17301704 spin_unlock_irqrestore (& cctx -> lock , flags );
1731- kref_init (& fl -> refcount );
17321705
17331706 return 0 ;
17341707}
0 commit comments