|
@@ -31,6 +31,7 @@
|
|
#include <linux/slab.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/string.h>
|
|
#include <linux/string.h>
|
|
#include <linux/vmalloc.h>
|
|
#include <linux/vmalloc.h>
|
|
|
|
+#include <linux/err.h>
|
|
|
|
|
|
#include "zram_drv.h"
|
|
#include "zram_drv.h"
|
|
|
|
|
|
@@ -583,7 +584,7 @@ static ssize_t disksize_store(struct device *dev,
|
|
struct zcomp *comp;
|
|
struct zcomp *comp;
|
|
struct zram_meta *meta;
|
|
struct zram_meta *meta;
|
|
struct zram *zram = dev_to_zram(dev);
|
|
struct zram *zram = dev_to_zram(dev);
|
|
- int err = -EINVAL;
|
|
|
|
|
|
+ int err;
|
|
|
|
|
|
disksize = memparse(buf, NULL);
|
|
disksize = memparse(buf, NULL);
|
|
if (!disksize)
|
|
if (!disksize)
|
|
@@ -595,18 +596,18 @@ static ssize_t disksize_store(struct device *dev,
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
|
|
|
|
comp = zcomp_create(zram->compressor, zram->max_comp_streams);
|
|
comp = zcomp_create(zram->compressor, zram->max_comp_streams);
|
|
- if (!comp) {
|
|
|
|
|
|
+ if (IS_ERR(comp)) {
|
|
pr_info("Cannot initialise %s compressing backend\n",
|
|
pr_info("Cannot initialise %s compressing backend\n",
|
|
zram->compressor);
|
|
zram->compressor);
|
|
- goto out_cleanup;
|
|
|
|
|
|
+ err = PTR_ERR(comp);
|
|
|
|
+ goto out_free_meta;
|
|
}
|
|
}
|
|
|
|
|
|
down_write(&zram->init_lock);
|
|
down_write(&zram->init_lock);
|
|
if (init_done(zram)) {
|
|
if (init_done(zram)) {
|
|
- up_write(&zram->init_lock);
|
|
|
|
pr_info("Cannot change disksize for initialized device\n");
|
|
pr_info("Cannot change disksize for initialized device\n");
|
|
err = -EBUSY;
|
|
err = -EBUSY;
|
|
- goto out_cleanup;
|
|
|
|
|
|
+ goto out_destroy_comp;
|
|
}
|
|
}
|
|
|
|
|
|
zram->meta = meta;
|
|
zram->meta = meta;
|
|
@@ -614,12 +615,12 @@ static ssize_t disksize_store(struct device *dev,
|
|
zram->disksize = disksize;
|
|
zram->disksize = disksize;
|
|
set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);
|
|
set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);
|
|
up_write(&zram->init_lock);
|
|
up_write(&zram->init_lock);
|
|
-
|
|
|
|
return len;
|
|
return len;
|
|
|
|
|
|
-out_cleanup:
|
|
|
|
- if (comp)
|
|
|
|
- zcomp_destroy(comp);
|
|
|
|
|
|
+out_destroy_comp:
|
|
|
|
+ up_write(&zram->init_lock);
|
|
|
|
+ zcomp_destroy(comp);
|
|
|
|
+out_free_meta:
|
|
zram_meta_free(meta);
|
|
zram_meta_free(meta);
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|