lkml.org 
[lkml]   [2016]   [Feb]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[QUEUED v20160212 14/19] stm class: Fix unlocking braino in the error path
    Date
    If an illegal attempt is made to unlink stm source device from an
    stm device, the stm device's link spinlock mistakenly remains locked.
    While this really shouldn't happen (there's a warning in place), the
    locking should remain in order so that we can still recover from this
    situation if it indeed does happen.

    This patch unifies the unlocking in the exit path of
    __stm_source_link_drop() to fix this.

    Reported-by: Laurent Fert <laurent.fert@intel.com>
    Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    ---
    drivers/hwtracing/stm/core.c | 7 +++----
    1 file changed, 3 insertions(+), 4 deletions(-)

    diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c
    index 385db65994..fb5a6a582b 100644
    --- a/drivers/hwtracing/stm/core.c
    +++ b/drivers/hwtracing/stm/core.c
    @@ -816,10 +816,8 @@ static void __stm_source_link_drop(struct stm_source_device *src,
    spin_lock(&stm->link_lock);
    spin_lock(&src->link_lock);
    link = srcu_dereference_check(src->link, &stm_source_srcu, 1);
    - if (WARN_ON_ONCE(link != stm)) {
    - spin_unlock(&src->link_lock);
    - return;
    - }
    + if (WARN_ON_ONCE(link != stm))
    + goto unlock;

    stm_output_free(link, &src->output);
    list_del_init(&src->link_entry);
    @@ -827,6 +825,7 @@ static void __stm_source_link_drop(struct stm_source_device *src,
    stm_put_device(link);
    rcu_assign_pointer(src->link, NULL);

    +unlock:
    spin_unlock(&src->link_lock);
    spin_unlock(&stm->link_lock);
    }
    --
    2.7.0
    \
     
     \ /
      Last update: 2016-02-12 18:21    [W:4.375 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site