Skip to contentSkip to conversation

blk-rq-qos: fix first node deletion of rq_qos_del()

PATCH In review Tejun Heo 2 participants 2 messages Oct 15, 2019 Block layer

lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/1 blk-rq-qos: fix first node deletion of rq_qos_del()

rq_qos_del() incorrectly assigns the node being deleted to the head if it was the first on the list in the !prev path. Fix it by iterating with ** instead.

Cc Josef Bacik <[email protected]>
Fixes a79050434b45 ("blk-rq-qos: refactor out common elements of blk-wbt")
Cc [email protected] # v4.19+
---
 block/blk-rq-qos.h |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
block/blk-rq-qos.h +5 -8
@@ -108,16 +108,13 @@ static inline void rq_qos_add(struct req
 
 static inline void rq_qos_del(struct request_queue *q, struct rq_qos *rqos)
 {
-	struct rq_qos *cur, *prev = NULL;
-	for (cur = q->rq_qos; cur; cur = cur->next) {
-		if (cur == rqos) {
-			if (prev)
-				prev->next = rqos->next;
-			else
-				q->rq_qos = cur;
+	struct rq_qos **cur;
+
+	for (cur = &q->rq_qos; *cur; cur = &(*cur)->next) {
+		if (*cur == rqos) {
+			*cur = rqos->next;
 			break;
 		}
-		prev = cur;
 	}
 
 	blk_mq_debugfs_unregister_rqos(rqos);
maintainer
#1 lore raw
Quoted 3 lines · Tejun Heo

rq_qos_del() incorrectly assigns the node being deleted to the head if it was the first on the list in the !prev path. Fix it by iterating with ** instead.

Well, that's unfortunate... Applied.

Signature · 1 line
Jens Axboe