From patchwork Thu Sep 13 01:39:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: axel lin X-Patchwork-Id: 1449881 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 62601DF238 for ; Thu, 13 Sep 2012 01:39:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753074Ab2IMBjy (ORCPT ); Wed, 12 Sep 2012 21:39:54 -0400 Received: from mail-oa0-f46.google.com ([209.85.219.46]:38682 "EHLO mail-oa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751764Ab2IMBjx (ORCPT ); Wed, 12 Sep 2012 21:39:53 -0400 Received: by oago6 with SMTP id o6so1490746oag.19 for ; Wed, 12 Sep 2012 18:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:x-mailer:content-transfer-encoding:mime-version; bh=qw78WX4MUC4IEroNzfIXnFtYl74chFGcltF84IP1PlA=; b=jodlxKHLGa/QOHPf4I0KueF0Fog2cIS/NvdEtYL0sNImgMVDIgZii5m0ZhDe0Moghg 2gRb7rGcMR4dB1vpxe7M8zO0nZ1vUyfiWeInH8TNz65LVcdJ2yWw+CcJrt9VgI/R5P+/ rLxxnYtFWHyE8YLRtn2d3YB6siW4B5nrRmj66r4cl2Jb4niQHALZbr1KpI1jPcaegiIq LpCTYI1kOyozdWrBMl1akIauTxMzq5fNmuy4oZ+GkEmuSgf2RrdMkfxpSsGaO4KYqwKb UeMOHUlAWsKMxtXxZ/ch2agQiPjHhRNAGEYw8JM6MW13d3RY0h/a4Fr+1/5J+X4eHZ3D JViw== Received: by 10.60.7.99 with SMTP id i3mr283175oea.86.1347500392938; Wed, 12 Sep 2012 18:39:52 -0700 (PDT) Received: from [114.39.96.237] (114-39-96-237.dynamic.hinet.net. [114.39.96.237]) by mx.google.com with ESMTPS id l10sm17884736oeb.13.2012.09.12.18.39.50 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Sep 2012 18:39:52 -0700 (PDT) Message-ID: <1347500387.7434.3.camel@phoenix> Subject: [PATCH 2/2] HID: hid-sensor-hub: Fix sensor_hub_probe error handling From: Axel Lin To: Jiri Kosina Cc: srinivas pandruvada , Jonathan Cameron , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 13 Sep 2012 09:39:47 +0800 In-Reply-To: <1347500288.7434.1.camel@phoenix> References: <1347500288.7434.1.camel@phoenix> X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Fix below issues in sensor_hub_probe error handling: 1. In the case of goto err_close, hid_hw_stop(hdev) is called twice. Fix it. 2. If fails to allocate MFD device name, we also need to free all successfully allocated names in previous iterations. Signed-off-by: Axel Lin --- drivers/hid/hid-sensor-hub.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 50bc8c7..8bd7620 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -584,7 +584,7 @@ static int sensor_hub_probe(struct hid_device *hdev, hid_err(hdev, "Failed MFD device name\n"); ret = -ENOMEM; - goto err_free_cells; + goto err_free_names; } sd->hid_sensor_hub_client_devs[ sd->hid_sensor_client_cnt].name = name; @@ -608,10 +608,8 @@ static int sensor_hub_probe(struct hid_device *hdev, err_free_names: for (i = 0; i < sd->hid_sensor_client_cnt ; ++i) kfree(sd->hid_sensor_hub_client_devs[i].name); -err_free_cells: kfree(sd->hid_sensor_hub_client_devs); err_close: - hid_hw_stop(hdev); hid_hw_close(hdev); err_stop_hw: hid_hw_stop(hdev);