[Xen-devel] [PATCH 1/3] Consistent use for lock variable

Artem Mygaiev posted 3 patches 6 years, 4 months ago
[Xen-devel] [PATCH 1/3] Consistent use for lock variable
Posted by Artem Mygaiev 6 years, 4 months ago
... for both lock and unlock

Coverity-ID: 1381840
Signed-off-by: Artem Mygaiev <artem_mygaiev@epam.com>
---
 xen/xsm/flask/avc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/xsm/flask/avc.c b/xen/xsm/flask/avc.c
index 87ea38b7a0..3a9507f62a 100644
--- a/xen/xsm/flask/avc.c
+++ b/xen/xsm/flask/avc.c
@@ -320,7 +320,7 @@ static inline int avc_reclaim_node(void)
         head = &avc_cache.slots[hvalue];
         lock = &avc_cache.slots_lock[hvalue];
 
-        spin_lock_irqsave(&avc_cache.slots_lock[hvalue], flags);
+        spin_lock_irqsave(lock, flags);
         rcu_read_lock(&avc_rcu_lock);
         hlist_for_each_entry(node, next, head, list)
         {
-- 
2.20.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH 1/3] Consistent use for lock variable
Posted by Julien Grall 6 years ago
Hi Artem,

Apologies for the late answer.

On 09/10/2019 15:20, Artem Mygaiev wrote:
> ... for both lock and unlock

I would suggest the following commit message:

xen/xsm: Use the same lock for lock and unlock

The function avc_reclaim_mode() is not using the same variable for 
locking and unlocking. While the underlying spinlock is the same, 
coverity will get confused and think the lock was not released.

Update the code to use the same variable for the lock and unlock part.

> 
> Coverity-ID: 1381840
> Signed-off-by: Artem Mygaiev <artem_mygaiev@epam.com>

Acked-by: Julien Grall <julien@xen.org>

We also need an hack from Daniel. @Daniel, are you happy with the change?

> ---
>   xen/xsm/flask/avc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/xsm/flask/avc.c b/xen/xsm/flask/avc.c
> index 87ea38b7a0..3a9507f62a 100644
> --- a/xen/xsm/flask/avc.c
> +++ b/xen/xsm/flask/avc.c
> @@ -320,7 +320,7 @@ static inline int avc_reclaim_node(void)
>           head = &avc_cache.slots[hvalue];
>           lock = &avc_cache.slots_lock[hvalue];
>   
> -        spin_lock_irqsave(&avc_cache.slots_lock[hvalue], flags);
> +        spin_lock_irqsave(lock, flags);
>           rcu_read_lock(&avc_rcu_lock);
>           hlist_for_each_entry(node, next, head, list)
>           {
> 

Cheers,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel