Skip to contentSkip to conversation

master - raid: use internal variables for array alloc

PATCH Zdenek Kabelac 1 participant 1 message Apr 8, 2014

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=96cf9dc0170d8a807ecac3956a80c3f51cfe48c0
Commit:        96cf9dc0170d8a807ecac3956a80c3f51cfe48c0
Parent:        89615af349056e3a34788a8b6c0842100389d2b8
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Fri Apr 4 21:19:58 2014 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Tue Apr 8 11:00:13 2014 +0200

raid: use internal variables for array alloc

Don't use passed pointer when allocating policies' array. (In case policy_argc would be NULL, this would have caused NULL dereference).

---
 lib/activate/activate.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
lib/activate/activate.c +2 -2
index 6667dfc..4d3f8fe 100644
@@ -1121,9 +1121,9 @@ int lv_cache_policy_info(struct logical_volume *lv,
 		*policy_argc = status->policy_argc;
 	if (policy_argv) {
 		if (!(*policy_argv =
-		      dm_pool_zalloc(mem, sizeof(char *) * *policy_argc)))
+		      dm_pool_zalloc(mem, sizeof(char *) * status->policy_argc)))
 			return_0;
-		for (i = 0; i < *policy_argc; i++)
+		for (i = 0; i < status->policy_argc; ++i)
 			if (!((*policy_argv)[i] =
 			      dm_pool_strdup(mem, status->policy_argv[i])))
 				return_0;