Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 02c9fbde authored by Ming Lei's avatar Ming Lei Committed by Pradeep Pragallapati
Browse files

BACKPORT: blk-mq: clear stale request in tags->rq[] before freeing one request pool



refcount_inc_not_zero() in bt_tags_iter() still may read one freed
request.

Fix the issue by the following approach:

1) hold a per-tags spinlock when reading ->rqs[tag] and calling
refcount_inc_not_zero in bt_tags_iter()

2) clearing stale request referred via ->rqs[tag] before freeing
request pool, the per-tags spinlock is held for clearing stale
->rq[tag]

So after we cleared stale requests, bt_tags_iter() won't observe
freed request any more, also the clearing will wait for pending
request reference.

The idea of clearing ->rqs[] is borrowed from John Garry's previous
patch and one recent David's patch.

Tested-by: default avatarJohn Garry <john.garry@huawei.com>
Reviewed-by: default avatarDavid Jeffery <djeffery@redhat.com>
Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarMing Lei <ming.lei@redhat.com&gt;.>

Bug: 197804811
Change-Id: If49478d7b05d3f5b0a26966ddf9ae764cf2fb6b0
[Upstream: cherry picked from commit bd63141d585bef14f4caf111f6d0e27fe2300ec6]
[Todd: refactored to avoid breaking KMI ]
Signed-off-by: default avatarPradeep P V K <pragalla@codeaurora.org>
Signed-off-by: default avatarTodd Kjos <tkjos@google.com>
Git-commit: bb96e7f45dc6ac1d6ec12190f1f286e3014fb068
Git-repo: https://android.googlesource.com/kernel/common/


Signed-off-by: default avatarPradeep P V K <quic_pragalla@quicinc.com>
parent f3b26aea
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment