lkml.org 
[lkml]   [2022]   [Aug]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] rxrpc: fix bad unlock balance in rxrpc_do_sendmsg
On Mon, Aug 22, 2022 at 07:55:27PM +0600, Khalid Masum wrote:
> >
> > /*
> > + * @holding_mutex: An indication whether caller can still holds
> > + * the call->user_mutex when returned to caller.
>
> Maybe we can use mutex_is_locked instead of using the holding_mutex
> parameter to get whether call->user_mutex is still held.

That doesn't work. What if there is contention for the lock and someone
else took it. Locks under contention are sort of the whole point of
locking so it's highly likely.

I do kind of feel the code has a layering violation. I'd prefer instead
of "I am setting this variable to true to reflect the caller blah blah",
the variable could just be set in the caller. I'd probably flip it
around and call it "dropped_lock" instead of "holding_lock".

bool dropped_lock = false;

...

if (!dropped_lock)
mutex_unlock();

That way only the callers and the function which drops the lock need to
be involved with setting the variable.

regards,
dan carpenter

\
 
 \ /
  Last update: 2022-08-22 16:08    [W:0.096 / U:1.724 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site