Skip to content

Commit 656fe3d

Browse files
committed
linuxkm/{module_hooks.c,linuxkm_wc_port.h}: in wc_lkm_LockMutex(), when interruptible, check for signals, and add __must_check attribute.
1 parent d47108c commit 656fe3d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

linuxkm/linuxkm_wc_port.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,7 @@
13981398
return 0;
13991399
}
14001400

1401-
static inline int wc_LockMutex(wolfSSL_Mutex* m)
1401+
static __must_check inline int wc_LockMutex(wolfSSL_Mutex* m)
14021402
{
14031403
if (in_nmi() || hardirq_count() || in_softirq())
14041404
return -1;
@@ -1443,14 +1443,14 @@
14431443
/* wc_lkm_LockMutex() can't be used inline in __PIE__ objects, due to
14441444
* direct access to pv_ops.
14451445
*/
1446-
static __always_inline int wc_LockMutex(wolfSSL_Mutex *m)
1446+
static __must_check __always_inline int wc_LockMutex(wolfSSL_Mutex *m)
14471447
{
14481448
return WC_PIE_INDIRECT_SYM(wc_lkm_LockMutex)(m);
14491449
}
14501450

14511451
#else /* !__PIE__ */
14521452

1453-
static __always_inline int wc_LockMutex(wolfSSL_Mutex *m)
1453+
static __must_check __always_inline int wc_LockMutex(wolfSSL_Mutex *m)
14541454
{
14551455
return wc_lkm_LockMutex(m);
14561456
}

linuxkm/module_hooks.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,14 @@ int wc_lkm_LockMutex(wolfSSL_Mutex* m)
172172
}
173173
else {
174174
for (;;) {
175+
int sig_ret = wc_linuxkm_check_for_intr_signals();
176+
if (sig_ret)
177+
return sig_ret;
178+
cond_resched();
175179
if (spin_trylock_irqsave(&m->lock, irq_flags)) {
176180
m->irq_flags = irq_flags;
177181
return 0;
178182
}
179-
cond_resched();
180183
}
181184
}
182185
__builtin_unreachable();

0 commit comments

Comments
 (0)