From patchwork Fri Jan 24 00:00:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Courtney Cavin X-Patchwork-Id: 3532431 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A09269F39B for ; Thu, 23 Jan 2014 23:59:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B8D1C201B6 for ; Thu, 23 Jan 2014 23:59:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF44220181 for ; Thu, 23 Jan 2014 23:59:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755187AbaAWX7Z (ORCPT ); Thu, 23 Jan 2014 18:59:25 -0500 Received: from seldrel01.sonyericsson.com ([212.209.106.2]:19745 "EHLO seldrel01.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751957AbaAWX7Y (ORCPT ); Thu, 23 Jan 2014 18:59:24 -0500 From: Courtney Cavin To: CC: , Subject: [PATCH 03/15] Input: synaptics-rmi4 - don't free devices directly Date: Thu, 23 Jan 2014 16:00:11 -0800 Message-ID: <1390521623-6491-4-git-send-email-courtney.cavin@sonymobile.com> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1390521623-6491-3-git-send-email-courtney.cavin@sonymobile.com> References: <1390521623-6491-1-git-send-email-courtney.cavin@sonymobile.com> <1390521623-6491-2-git-send-email-courtney.cavin@sonymobile.com> <1390521623-6491-3-git-send-email-courtney.cavin@sonymobile.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Devices use a kobject to manage references, do not delete the memory while still referenced. Instead, call put_device() to release the reference. Cc: Christopher Heiny Cc: Dmitry Torokhov Signed-off-by: Courtney Cavin --- drivers/input/rmi4/rmi_bus.c | 8 +++++--- drivers/input/rmi4/rmi_driver.c | 6 +----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c index 8a939f3..cd7bfbd 100644 --- a/drivers/input/rmi4/rmi_bus.c +++ b/drivers/input/rmi4/rmi_bus.c @@ -94,8 +94,7 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport) return -EINVAL; } - rmi_dev = devm_kzalloc(xport->dev, - sizeof(struct rmi_device), GFP_KERNEL); + rmi_dev = kzalloc(sizeof(struct rmi_device), GFP_KERNEL); if (!rmi_dev) return -ENOMEM; @@ -112,8 +111,10 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport) rmi_physical_setup_debugfs(rmi_dev); error = device_register(&rmi_dev->dev); - if (error) + if (error) { + put_device(&rmi_dev->dev); return error; + } dev_dbg(xport->dev, "%s: Registered %s as %s.\n", __func__, pdata->sensor_name, dev_name(&rmi_dev->dev)); @@ -240,6 +241,7 @@ int rmi_register_function(struct rmi_function *fn) dev_err(&rmi_dev->dev, "Failed device_register function device %s\n", dev_name(&fn->dev)); + put_device(&fn->dev); goto error_exit; } diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c index 5c6379c..4965589 100644 --- a/drivers/input/rmi4/rmi_driver.c +++ b/drivers/input/rmi4/rmi_driver.c @@ -557,15 +557,11 @@ static int create_function(struct rmi_device *rmi_dev, error = rmi_register_function(fn); if (error) - goto err_free_mem; + return error; list_add_tail(&fn->node, &data->function_list); return 0; - -err_free_mem: - kfree(fn); - return error; } /*