[PATCH] dm-cache: return -EINVAL, not -ENOMEM, if the user specifies unknown policy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



dm-cache: return -EINVAL, not -ENOMEM, if the user specifies unknown 
policy

Signed-off-by: Mikulas Patocka <mpatocka@xxxxxxxxxx>

---
 drivers/md/dm-cache-policy.c |    4 ++--
 drivers/md/dm-cache-target.c |    8 +++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

Index: linux-3.10.13-fast/drivers/md/dm-cache-target.c
===================================================================
--- linux-3.10.13-fast.orig/drivers/md/dm-cache-target.c	2013-10-01 16:30:54.000000000 +0200
+++ linux-3.10.13-fast/drivers/md/dm-cache-target.c	2013-10-01 17:29:43.000000000 +0200
@@ -1865,15 +1865,17 @@ static int set_config_values(struct cach
 static int create_cache_policy(struct cache *cache, struct cache_args *ca,
 			       char **error)
 {
-	cache->policy =	dm_cache_policy_create(ca->policy_name,
+	struct dm_cache_policy *p = dm_cache_policy_create(ca->policy_name,
 					       cache->cache_size,
 					       cache->origin_sectors,
 					       cache->sectors_per_block);
-	if (!cache->policy) {
+	if (IS_ERR(p)) {
 		*error = "Error creating cache's policy";
-		return -ENOMEM;
+		return PTR_ERR(p);
 	}
 
+	cache->policy = p;
+
 	return 0;
 }
 
Index: linux-3.10.13-fast/drivers/md/dm-cache-policy.c
===================================================================
--- linux-3.10.13-fast.orig/drivers/md/dm-cache-policy.c	2013-10-01 17:29:50.000000000 +0200
+++ linux-3.10.13-fast/drivers/md/dm-cache-policy.c	2013-10-01 17:30:05.000000000 +0200
@@ -119,13 +119,13 @@ struct dm_cache_policy *dm_cache_policy_
 	type = get_policy(name);
 	if (!type) {
 		DMWARN("unknown policy type");
-		return NULL;
+		return ERR_PTR(-EINVAL);
 	}
 
 	p = type->create(cache_size, origin_size, cache_block_size);
 	if (!p) {
 		put_policy(type);
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 	}
 	p->private = type;
 

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux