Skip to contentSkip to conversation

check head in page_chain_del for every loop

PATCH New Ming Li 1 participant 1 message Apr 15, 2021 DRBD driver

lore
Share & tools
lore

Ming Li

author
#0 lore raw

PATCH 1/1 check head in page_chain_del for every loop

From: Ming Li <[email protected]>

there will be crash when we get a NULL head in loop.

---
 drbd/drbd_receiver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drbd/drbd_receiver.c +2 -2
index f127a235..28fb2e06 100644
@@ -280,12 +280,12 @@ static struct page *page_chain_del(struct page **head, int count)
 	BUG_ON(!head);
 
 	page = READ_ONCE(*head);
-	if (!page)
-		return NULL;
 
 	do {
 		n = count;
 		rv_head = page;
+		if (!page)
+			return NULL;
 		while (true) {
 			tmp = page_chain_next(page);
 			if (--n == 0)
Signature · 1 line
2.24.3 (Apple Git-128)