zram: check comp algorithm availability earlier
[firefly-linux-kernel-4.4.55.git] / drivers / block / zram / zram_drv.c
index d94696b28a852b8c974cd58a7515b1ad5a1ea051..fb655e8d1e3b17bf4cda9fd09593bc7dc770f78d 100644 (file)
@@ -378,6 +378,9 @@ static ssize_t comp_algorithm_store(struct device *dev,
        if (sz > 0 && zram->compressor[sz - 1] == '\n')
                zram->compressor[sz - 1] = 0x00;
 
+       if (!zcomp_available_algorithm(zram->compressor))
+               len = -EINVAL;
+
        up_write(&zram->init_lock);
        return len;
 }