From patchwork Mon Mar 4 14:00:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Mossberg X-Patchwork-Id: 15221 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2F6C123E4A for ; Mon, 4 Mar 2013 14:00:48 +0000 (UTC) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by fiordland.canonical.com (Postfix) with ESMTP id C1F2BA190CB for ; Mon, 4 Mar 2013 14:00:47 +0000 (UTC) Received: by mail-ve0-f179.google.com with SMTP id da11so4633495veb.38 for ; Mon, 04 Mar 2013 06:00:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:date:message-id:x-mailer:mime-version:cc :subject:x-beenthere:x-mailman-version:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :content-type:content-transfer-encoding:sender:errors-to :x-gm-message-state; bh=1z27TuDNH3t7pRccqPKcy3KsMbYasX3UUfWKXAIQ050=; b=e5LS15EHN+X/P9Y8R7UJ7vJ8TeTuryITcTsjUwulGYdUjCHCDvVZh+QF5Gnsf6GIB+ XiCINiWeYf0jya46P1MJtD3rEbcLKpkfU7OxeWKwZuUzC/Ajck22LIop7bz/AscpKBEi YoCb82RP/FxtXQ0d3GwRxfjQ217Ghc4LYJD7GwLqLrcsD4jlNkjQd40rne1eUoOxg3wf JVzIiASNLJdOkzThG1bC/0TO2bMQ3GDhNr05D8HyoNWYu0oxvN4hNyBrEogjgMVAJokn 98kSKuibTZhmOCUkPdE4DV6HOnfldT3COAq0e2quCj3IGGkG5dnxKkH0Ou5tFK0Wg+PR YCDQ== X-Received: by 10.220.39.69 with SMTP id f5mr7779534vce.45.1362405647262; Mon, 04 Mar 2013 06:00:47 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp57704veb; Mon, 4 Mar 2013 06:00:46 -0800 (PST) X-Received: by 10.205.127.11 with SMTP id gy11mr7496956bkc.54.1362405645817; Mon, 04 Mar 2013 06:00:45 -0800 (PST) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id gk9si5568145bkc.90.2013.03.04.06.00.44; Mon, 04 Mar 2013 06:00:45 -0800 (PST) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1UCVwV-0004jn-NU; Mon, 04 Mar 2013 14:00:39 +0000 Received: from eu1sys200aog119.obsmtp.com ([207.126.144.147]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1UCVwU-0004ji-Nm for linaro-mm-sig@lists.linaro.org; Mon, 04 Mar 2013 14:00:38 +0000 Received: from beta.dmz-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob119.postini.com ([207.126.147.11]) with SMTP ID DSNKUTSpA2EALVLrm8pECQ6Xw3kY29ez5jJz@postini.com; Mon, 04 Mar 2013 14:00:37 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id D9D1F3D; Mon, 4 Mar 2013 13:59:44 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 7462058; Mon, 4 Mar 2013 07:46:56 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 732B724C2E5; Mon, 4 Mar 2013 15:00:26 +0100 (CET) Received: from steludxu2808.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server id 8.3.83.0; Mon, 4 Mar 2013 15:00:33 +0100 From: Johan Mossberg To: Date: Mon, 4 Mar 2013 15:00:24 +0100 Message-ID: <1362405624-12084-1-git-send-email-johan.mossberg@stericsson.com> X-Mailer: git-send-email 1.7.4.3 MIME-Version: 1.0 Cc: linaro-mm-sig@lists.linaro.org Subject: [Linaro-mm-sig] [PATCH] gpu: ion: Copy name string in client and heap create functions X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQlucWp9/jR9kWjDxi5e4QKfFLdPhV4RkX/WqtmQb0MYRm5GKmn/aezTT5ztycE4habSJjw4 ion_client_create and ion_heap_create assumes the caller will keep the name string valid forever. In my opinion this is not the expected behavior, it also makes it difficult to have dynamically created names. Signed-off-by: Johan Mossberg --- drivers/gpu/ion/ion.c | 11 +++++++---- drivers/gpu/ion/ion_heap.c | 3 ++- drivers/gpu/ion/ion_priv.h | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c index 8fd61b3..b0ad01b 100644 --- a/drivers/gpu/ion/ion.c +++ b/drivers/gpu/ion/ion.c @@ -57,6 +57,8 @@ struct ion_device { struct dentry *debug_root; }; +#define CLIENT_NAME_LEN 16 + /** * struct ion_client - a process/hw block local address space * @node: node in the tree of all clients @@ -75,7 +77,7 @@ struct ion_client { struct ion_device *dev; struct rb_root handles; struct mutex lock; - const char *name; + char name[CLIENT_NAME_LEN]; struct task_struct *task; pid_t pid; struct dentry *debug_root; @@ -598,14 +600,14 @@ static int ion_debug_client_show(struct seq_file *s, void *unused) names[id] = handle->buffer->heap->name; sizes[id] += handle->buffer->size; } - mutex_unlock(&client->lock); - seq_printf(s, "%16.16s: %16.16s\n", "heap_name", "size_in_bytes"); for (i = 0; i < ION_NUM_HEAP_IDS; i++) { if (!names[i]) continue; seq_printf(s, "%16.16s: %16u\n", names[i], sizes[i]); } + mutex_unlock(&client->lock); + return 0; } @@ -655,7 +657,8 @@ struct ion_client *ion_client_create(struct ion_device *dev, client->dev = dev; client->handles = RB_ROOT; mutex_init(&client->lock); - client->name = name; + strncpy(client->name, name, CLIENT_NAME_LEN); + client->name[CLIENT_NAME_LEN - 1] = '\0'; client->task = task; client->pid = pid; diff --git a/drivers/gpu/ion/ion_heap.c b/drivers/gpu/ion/ion_heap.c index 225ef94..96dd70b 100644 --- a/drivers/gpu/ion/ion_heap.c +++ b/drivers/gpu/ion/ion_heap.c @@ -160,7 +160,8 @@ struct ion_heap *ion_heap_create(struct ion_platform_heap *heap_data) return ERR_PTR(-EINVAL); } - heap->name = heap_data->name; + strncpy(heap->name, heap_data->name, HEAP_NAME_LEN); + heap->name[HEAP_NAME_LEN - 1] = '\0'; heap->id = heap_data->id; return heap; } diff --git a/drivers/gpu/ion/ion_priv.h b/drivers/gpu/ion/ion_priv.h index c116921..3296ba4 100644 --- a/drivers/gpu/ion/ion_priv.h +++ b/drivers/gpu/ion/ion_priv.h @@ -107,6 +107,8 @@ struct ion_heap_ops { struct vm_area_struct *vma); }; +#define HEAP_NAME_LEN 16 + /** * struct ion_heap - represents a heap in the system * @node: rb node to put the heap on the device's tree of heaps @@ -131,7 +133,7 @@ struct ion_heap { enum ion_heap_type type; struct ion_heap_ops *ops; unsigned int id; - const char *name; + char name[HEAP_NAME_LEN]; int (*debug_show)(struct ion_heap *heap, struct seq_file *, void *); };