summaryrefslogtreecommitdiffstats
path: root/drivers/block/zram/zcomp.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/zram/zcomp.c')
-rw-r--r--drivers/block/zram/zcomp.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c
index d5919031ca8b..5647d8fe1dc1 100644
--- a/drivers/block/zram/zcomp.c
+++ b/drivers/block/zram/zcomp.c
@@ -9,6 +9,7 @@
#include <linux/kernel.h>
#include <linux/string.h>
+#include <linux/err.h>
#include <linux/slab.h>
#include <linux/wait.h>
#include <linux/sched.h>
@@ -319,9 +320,10 @@ void zcomp_destroy(struct zcomp *comp)
/*
* search available compressors for requested algorithm.
- * allocate new zcomp and initialize it. return NULL
- * if requested algorithm is not supported or in case
- * of init error
+ * allocate new zcomp and initialize it. return compressing
+ * backend pointer or ERR_PTR if things went bad. ERR_PTR(-EINVAL)
+ * if requested algorithm is not supported, ERR_PTR(-ENOMEM) in
+ * case of allocation error.
*/
struct zcomp *zcomp_create(const char *compress, int max_strm)
{
@@ -330,11 +332,11 @@ struct zcomp *zcomp_create(const char *compress, int max_strm)
backend = find_backend(compress);
if (!backend)
- return NULL;
+ return ERR_PTR(-EINVAL);
comp = kzalloc(sizeof(struct zcomp), GFP_KERNEL);
if (!comp)
- return NULL;
+ return ERR_PTR(-ENOMEM);
comp->backend = backend;
if (max_strm > 1)
@@ -343,7 +345,7 @@ struct zcomp *zcomp_create(const char *compress, int max_strm)
zcomp_strm_single_create(comp);
if (!comp->stream) {
kfree(comp);
- return NULL;
+ return ERR_PTR(-ENOMEM);
}
return comp;
}