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

Oliver Neukum
2022-05-03T07:42:05Z

On 02.05.22 13:05, Tetsuo Handa wrote:
> On 2022/05/02 19:46, Oliver Neukum wrote:
>>
>> When could this ever happen? Either the device is disconnected, then
>> you'll go to 'exit' or the refcount will go back to something >0, won't it?
>>
> (Step 0) Say, ictx->users is initially 1.
>
> (Step 1) display_open() increments via refcount_inc_not_zero(), now is 2.
>
> (Step 2) imon_disconnect() decrements via refcount_dec_and_test(), now is 1.
>
> (Step 3) if retval != 0, display_open() needs to undo (Step 1) via
> refcount_dec_and_test(), now is 0.
>
> because imon_disconnect() can be called while display_open() is in progress...
>
Hi,

thank you. I did not think of error handling. You are correct.

Regards
Oliver