From: Jan Beulich Date: Fri, 24 Jul 2020 08:18:30 +0000 (+0200) Subject: lockprof: don't leave locks uninitialized upon allocation failure X-Git-Tag: archive/raspbian/4.16.0+51-g0941d6cb-1+rpi1~2^2~42^2~1825 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=82cba984b2e37496360ef2bf22e529a53c084631;p=xen.git lockprof: don't leave locks uninitialized upon allocation failure Even if a specific struct lock_profile instance can't be allocated, the lock itself should still be functional. As this isn't a production use feature, also log a message in the event that the profiling struct can't be allocated. Fixes: d98feda5c756 ("Make lock profiling usable again") Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- diff --git a/xen/include/xen/spinlock.h b/xen/include/xen/spinlock.h index 468b9ac9ef..c0e7690a6c 100644 --- a/xen/include/xen/spinlock.h +++ b/xen/include/xen/spinlock.h @@ -103,10 +103,16 @@ struct lock_profile_qhead { do { \ struct lock_profile *prof; \ prof = xzalloc(struct lock_profile); \ - if (!prof) break; \ + (s)->l = (spinlock_t)_SPIN_LOCK_UNLOCKED(prof); \ + if ( !prof ) \ + { \ + printk(XENLOG_WARNING \ + "lock profiling unavailable for %p(%d)'s %s\n", \ + s, (s)->profile_head.idx, #l); \ + break; \ + } \ prof->name = #l; \ prof->lock = &(s)->l; \ - (s)->l = (spinlock_t)_SPIN_LOCK_UNLOCKED(prof); \ prof->next = (s)->profile_head.elem_q; \ (s)->profile_head.elem_q = prof; \ } while(0)