mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-22 23:13:01 +02:00
rcu: Return early if callback is not specified
[ Upstream commit 33b6a1f155
]
Currently the call_rcu() API does not check whether a callback
pointer is NULL. If NULL is passed, rcu_core() will try to invoke
it, resulting in NULL pointer dereference and a kernel crash.
To prevent this and improve debuggability, this patch adds a check
for NULL and emits a kernel stack trace to help identify a faulty
caller.
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>
Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
f994086704
commit
100040bff2
|
@ -2827,6 +2827,10 @@ void call_rcu(struct rcu_head *head, rcu_callback_t func)
|
||||||
/* Misaligned rcu_head! */
|
/* Misaligned rcu_head! */
|
||||||
WARN_ON_ONCE((unsigned long)head & (sizeof(void *) - 1));
|
WARN_ON_ONCE((unsigned long)head & (sizeof(void *) - 1));
|
||||||
|
|
||||||
|
/* Avoid NULL dereference if callback is NULL. */
|
||||||
|
if (WARN_ON_ONCE(!func))
|
||||||
|
return;
|
||||||
|
|
||||||
if (debug_rcu_head_queue(head)) {
|
if (debug_rcu_head_queue(head)) {
|
||||||
/*
|
/*
|
||||||
* Probable double call_rcu(), so leak the callback.
|
* Probable double call_rcu(), so leak the callback.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user