Skip to contentSkip to conversation

mm-z3fold-fix-possible-null-pointer-dereferencing.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message May 27, 2022

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/z3fold: fix possible null pointer dereferencing
has been removed from the -mm tree. Its filename was
mm-z3fold-fix-possible-null-pointer-dereferencing.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Miaohe Lin <[email protected]>
Subject: mm/z3fold: fix possible null pointer dereferencing
Date: Fri, 29 Apr 2022 14:40:43 +0800

alloc_slots could fail to allocate memory under heavy memory pressure. So we should check zhdr->slots against NULL to avoid future null pointer dereferencing.

---

 mm/z3fold.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
mm/z3fold.c renamed from mm/z3fold.c~mm-z3fold-fix-possible-null-pointer-dereferencing +11 -1
@@ -940,9 +940,19 @@ lookup:
 		}
 	}
 
-	if (zhdr && !zhdr->slots)
+	if (zhdr && !zhdr->slots) {
 		zhdr->slots = alloc_slots(pool, GFP_ATOMIC);
+		if (!zhdr->slots)
+			goto out_fail;
+	}
 	return zhdr;
+
+out_fail:
+	if (!kref_put(&zhdr->refcount, release_z3fold_page_locked)) {
+		add_to_unbuddied(pool, zhdr);
+		z3fold_page_unlock(zhdr);
+	}
+	return NULL;
 }
 
 /*

_

Patches currently in -mm which might be from [email protected] are