Re: [PATCH v2 (resend)] media: imon: reorganize serialization

Tetsuo Handa
2022-05-02T10:41:01Z

On 2022/05/02 19:26, Tetsuo Handa wrote:
> @@ -550,10 +548,15 @@ static int display_open(struct inode *inode, struct file *file)
>
> mutex_unlock(&ictx->lock);
>
> - if (retval && refcount_dec_and_test(&ictx->users))
> - free_imon_context(ictx);
> -
> + if (retval) {
> + mutex_unlock(&driver_lock);

Oops. This is mutex_lock(&driver_lock);.

> + if (refcount_dec_and_test(&ictx->users))
> + free_imon_context(ictx);
> + mutex_unlock(&driver_lock);
> + }
> + return retval;
> exit:
> + mutex_unlock(&driver_lock);
> return retval;
> }
>

But if you merely want to avoid adding "struct rcu_head rcu;" to "struct imon_context",
we can use synchronize_rcu(); kfree(ictx); sequence (at the cost of waiting for RCU
grace period inside free_imon_context()).