summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Peiffer <pierre.peiffer@stericsson.com>2011-07-18 18:29:14 +0200
committerPhilippe Langlais <philippe.langlais@stericsson.com>2012-05-22 11:06:57 +0200
commit29857a2c55f4d50d411ddcedd5346e3942880ce9 (patch)
tree7e37718f2e907defedc525d68dfeed8341aadb04
parent8ed2ca3781ca0e979245c9628fac06c0d31b5291 (diff)
U8500 NMF-CM: make creation of domains more robust
CM_ENGINE_CreateMemoryDomain() allows the creation of domains for some other client (process ID). Today, it doesn't check the existance of the target client, what can lead to an unused domain. This patch fixes it for forbidding the creation of domain for a non-existing client. ST-Ericsson ID: 352761 ST-Ericsson Linux next: - ST-Ericsson FOSS-OUT ID: Trivial Signed-off-by: Pierre Peiffer <pierre.peiffer@stericsson.com> Change-Id: Icf81e9a9c18ce204d0f3c472a1ee05b140567738
-rw-r--r--drivers/staging/nmf-cm/cm_syscall.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/drivers/staging/nmf-cm/cm_syscall.c b/drivers/staging/nmf-cm/cm_syscall.c
index f4be2c2d3d1..a687e0206a3 100644
--- a/drivers/staging/nmf-cm/cm_syscall.c
+++ b/drivers/staging/nmf-cm/cm_syscall.c
@@ -514,10 +514,25 @@ inline int cmld_CreateMemoryDomain(struct cm_process_priv *procPriv,
data.out.error = CM_ENGINE_CreateMemoryDomain(procPriv->pid,
&domain,
&data.out.handle);
- else
- data.out.error = CM_ENGINE_CreateMemoryDomain(data.in.client,
- &domain,
- &data.out.handle);
+ else {
+ /* Check if client is valid (ie already registered) */
+ struct list_head* head;
+ struct cm_process_priv *entry;
+
+ list_for_each(head, &process_list) {
+ entry = list_entry(head, struct cm_process_priv,
+ entry);
+ if (entry->pid == data.in.client)
+ break;
+ }
+ if (head == &process_list)
+ data.out.error = CM_INVALID_PARAMETER;
+ else
+ data.out.error =
+ CM_ENGINE_CreateMemoryDomain(data.in.client,
+ &domain,
+ &data.out.handle);
+ }
/* Copy results back to userspace */
if (copy_to_user(&param->out, &data.out, sizeof(data.out)))