slab: alien caches must not be initialized if the allocation of the alien cache failed
[GitHub/LineageOS/android_kernel_motorola_exynos9610.git] / mm / zswap.c
index d39581a076c3aed1e9db7b2408c3f8da9ef60415..ebb0bc88c5f72c0550c93c1af34634ef3eef353b 100644 (file)
@@ -970,6 +970,12 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset,
        u8 *src, *dst;
        struct zswap_header *zhdr;
 
+       /* THP isn't supported */
+       if (PageTransHuge(page)) {
+               ret = -EINVAL;
+               goto reject;
+       }
+
        if (!zswap_enabled || !tree) {
                ret = -ENODEV;
                goto reject;
@@ -983,6 +989,15 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset,
                        ret = -ENOMEM;
                        goto reject;
                }
+
+               /* A second zswap_is_full() check after
+                * zswap_shrink() to make sure it's now
+                * under the max_pool_percent
+                */
+               if (zswap_is_full()) {
+                       ret = -ENOMEM;
+                       goto reject;
+               }
        }
 
        /* allocate entry */