From patchwork Mon Feb 3 18:16:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 24053 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B9C31202B2 for ; Mon, 3 Feb 2014 18:16:50 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id i4sf32110670oah.11 for ; Mon, 03 Feb 2014 10:16:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=DQfbsFhuUWu9MXU/wHao/YBgWykimhBKphzNBqXg25Y=; b=ZZsZtV9gcsQQfdHI1/JqgZs8m50QHbXBjv3mcefcFgmXDJtLwPNyO/zaKfz+aDC/X4 OWIgQPIPhXZFowESMKDyXBxyHeMdePeLiGrJnHUAPBA1TNnBOiFXV4NC+PD2hdvOZVHu P18Jf1u/GBXefYmTfz/zZxDETUIwheH8QBRA1pCbsO6HKhvEAaMtpk83CeyfykXqxIOw eT7xcPR2roLquptohYLmQpYrfZew+7zjyelRnFvvMjArxMw9UkczOPEVgpgsV7U6Ofe0 AiDj56qaDyjO/zkvlZ4fxvuD1kONnAOgKRIXY/VyZjp0IFPTYkGAD1r1G5pvn94bHydf DVBg== X-Gm-Message-State: ALoCoQncwOU+04kf9BxXf8YegsRXLw+lAFdVBYu9PZqLtAa8D7KVPwgomF3dU9epOWDkXG08auJQ X-Received: by 10.182.190.114 with SMTP id gp18mr14453018obc.37.1391451409750; Mon, 03 Feb 2014 10:16:49 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.50.171 with SMTP id s40ls1859577qga.17.gmail; Mon, 03 Feb 2014 10:16:49 -0800 (PST) X-Received: by 10.52.118.33 with SMTP id kj1mr1885782vdb.33.1391451409635; Mon, 03 Feb 2014 10:16:49 -0800 (PST) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id eb8si7039818vdb.151.2014.02.03.10.16.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Feb 2014 10:16:49 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id pa12so5082867veb.5 for ; Mon, 03 Feb 2014 10:16:49 -0800 (PST) X-Received: by 10.52.114.99 with SMTP id jf3mr143827vdb.66.1391451409532; Mon, 03 Feb 2014 10:16:49 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp174184vcz; Mon, 3 Feb 2014 10:16:49 -0800 (PST) X-Received: by 10.68.196.164 with SMTP id in4mr38637877pbc.128.1391451408651; Mon, 03 Feb 2014 10:16:48 -0800 (PST) Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by mx.google.com with ESMTPS id fu1si21469116pbc.254.2014.02.03.10.16.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Feb 2014 10:16:48 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.46 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.220.46; Received: by mail-pa0-f46.google.com with SMTP id rd3so7413617pab.33 for ; Mon, 03 Feb 2014 10:16:48 -0800 (PST) X-Received: by 10.66.182.199 with SMTP id eg7mr9305761pac.135.1391451408180; Mon, 03 Feb 2014 10:16:48 -0800 (PST) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id y9sm150496099pas.10.2014.02.03.10.16.47 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Feb 2014 10:16:47 -0800 (PST) From: John Stultz To: LKML Cc: Mitchel Humpherys , Greg KH , Colin Cross , Android Kernel Team , John Stultz Subject: [PATCH 11/16] staging: ion: Store a copy of the client name on client creation Date: Mon, 3 Feb 2014 10:16:23 -0800 Message-Id: <1391451388-23906-12-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1391451388-23906-1-git-send-email-john.stultz@linaro.org> References: <1391451388-23906-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Mitchel Humpherys Currently, we copy the pointer passed in to ion_client_create without making a copy of the string itself. This approach is problematic since it relies on the client keeping the name string in working order. Cc: Greg KH Cc: Colin Cross Cc: Android Kernel Team Signed-off-by: Mitchel Humpherys [jstultz: Minor commit subject tweaks] Signed-off-by: John Stultz --- drivers/staging/android/ion/ion.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 684f240..47163bd 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -734,19 +734,18 @@ struct ion_client *ion_client_create(struct ion_device *dev, task_unlock(current->group_leader); client = kzalloc(sizeof(struct ion_client), GFP_KERNEL); - if (!client) { - if (task) - put_task_struct(current->group_leader); - return ERR_PTR(-ENOMEM); - } + if (!client) + goto err_put_task_struct; client->dev = dev; client->handles = RB_ROOT; idr_init(&client->idr); mutex_init(&client->lock); - client->name = name; client->task = task; client->pid = pid; + client->name = kstrdup(name, GFP_KERNEL); + if (!client->name) + goto err_free_client; down_write(&dev->lock); p = &dev->clients.rb_node; @@ -775,6 +774,13 @@ struct ion_client *ion_client_create(struct ion_device *dev, up_write(&dev->lock); return client; + +err_free_client: + kfree(client); +err_put_task_struct: + if (task) + put_task_struct(current->group_leader); + return ERR_PTR(-ENOMEM); } EXPORT_SYMBOL(ion_client_create); @@ -799,6 +805,7 @@ void ion_client_destroy(struct ion_client *client) debugfs_remove_recursive(client->debug_root); up_write(&dev->lock); + kfree(client->name); kfree(client); } EXPORT_SYMBOL(ion_client_destroy);