From patchwork Mon Feb 17 21:58:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 24799 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f71.google.com (mail-pb0-f71.google.com [209.85.160.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B665520143 for ; Mon, 17 Feb 2014 21:59:04 +0000 (UTC) Received: by mail-pb0-f71.google.com with SMTP id jt11sf36922952pbb.10 for ; Mon, 17 Feb 2014 13:59:04 -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=xMerCgTXJI6YZE8NQTy855p+jTmn8WiDAuyI2CjBW1g=; b=ai5J1YQxK0HMEQZzG7uL+liScqp0PQM7DqFBBrKQNvVjcxnNVSYMFh0xB13k9khKJn FJSgy9oHZc1WGcbuIx0qbKodpotSY3fx7gBH+wZwTNw2b6W2y1r9yDZxwnO/3hgItk3Q B2JnJYx/IacTly8kE2bCsIngx7ZuU+aZTrkztdag7VHMhVTecnj5mCBU9kM8jcVgBqwD XcauEwGLNKnOM6cF9J7Sj3/gakNk8p2h76hwG0/FHcL4fvfr3E9/V6JuCaFjuwJq2/kb vE3H80Y0fmlFbFpmhEXK0s3a9eh5qbgi02igCOgOVoho4B7DBtTflHWbrRZ272rNn0RT z11A== X-Gm-Message-State: ALoCoQnwHrTMG36nHxnj4xp33ySlJ+AaNZ0vFJ0Nla82PkV8EAPZ8ELGbvwjzB/WiKwmtC4+aXpP X-Received: by 10.66.159.36 with SMTP id wz4mr11066269pab.14.1392674343987; Mon, 17 Feb 2014 13:59:03 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.106.165 with SMTP id e34ls1032143qgf.29.gmail; Mon, 17 Feb 2014 13:59:03 -0800 (PST) X-Received: by 10.52.119.178 with SMTP id kv18mr14072vdb.63.1392674343806; Mon, 17 Feb 2014 13:59:03 -0800 (PST) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id yx7si4819622vcb.125.2014.02.17.13.59.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Feb 2014 13:59:03 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id ij19so12205703vcb.20 for ; Mon, 17 Feb 2014 13:59:03 -0800 (PST) X-Received: by 10.220.159.4 with SMTP id h4mr18834177vcx.1.1392674343724; Mon, 17 Feb 2014 13:59:03 -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 u4csp169524vcz; Mon, 17 Feb 2014 13:59:03 -0800 (PST) X-Received: by 10.68.190.228 with SMTP id gt4mr29218263pbc.94.1392674342845; Mon, 17 Feb 2014 13:59:02 -0800 (PST) Received: from mail-pb0-f46.google.com (mail-pb0-f46.google.com [209.85.160.46]) by mx.google.com with ESMTPS id gx4si16083058pbc.81.2014.02.17.13.59.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Feb 2014 13:59:02 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.46 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.160.46; Received: by mail-pb0-f46.google.com with SMTP id um1so15795323pbc.19 for ; Mon, 17 Feb 2014 13:59:02 -0800 (PST) X-Received: by 10.67.5.7 with SMTP id ci7mr28604103pad.99.1392674342383; Mon, 17 Feb 2014 13:59:02 -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 x5sm49045254pbw.26.2014.02.17.13.59.01 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Feb 2014 13:59:01 -0800 (PST) From: John Stultz To: LKML Cc: Mitchel Humpherys , Greg KH , Colin Cross , Android Kernel Team , John Stultz Subject: [PATCH 08/14] staging: ion: Store a copy of the client name on client creation Date: Mon, 17 Feb 2014 13:58:36 -0800 Message-Id: <1392674322-9036-9-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1392674322-9036-1-git-send-email-john.stultz@linaro.org> References: <1392674322-9036-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.220.175 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 4869420..eac4bce 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -735,19 +735,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; @@ -776,6 +775,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); @@ -800,6 +806,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);