From patchwork Sun Feb 14 14:10:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 8302171 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 087D89F399 for ; Sun, 14 Feb 2016 14:11:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0DAEA20295 for ; Sun, 14 Feb 2016 14:11:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0CBD420266 for ; Sun, 14 Feb 2016 14:11:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751415AbcBNOLB (ORCPT ); Sun, 14 Feb 2016 09:11:01 -0500 Received: from mail-qg0-f44.google.com ([209.85.192.44]:32831 "EHLO mail-qg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751128AbcBNOLA (ORCPT ); Sun, 14 Feb 2016 09:11:00 -0500 Received: by mail-qg0-f44.google.com with SMTP id b35so94725783qge.0 for ; Sun, 14 Feb 2016 06:11:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=RAMa5ATrP83IzIEmq62lMFdI3vhYzQnje8Yj0LplH/s=; b=Haf+8dDaQX4+A7dT5bKFUqgYWc73zGpqM/743wXqzh7Ecu5eIw2qLWMTYkzOY0xAmO mvpJtmSwPVTJfEkyKPV7GkbiK4DJOrpZVDMoJkP8lR2TLGjveylAgWxYYkbsRvOOGnAM cqCHVJVomHrKcv+fzx4WNazhCL4zlPRx/HN1orlEsg6byq52/isdA3z+5INj3fdpdTxx atxsMhOgUaJSWUJ0RAs4r6q4zK8c/4qp7DMPJcntliIqo5kT7UXebpvFsTdBilTw83v9 Y0B7wO9vSYcH5Jb7Ta9GcTfNbAtOppHIMzE0rmrpIdb8xFhsxSqzRduIqbQP+vETl2Z9 w7jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RAMa5ATrP83IzIEmq62lMFdI3vhYzQnje8Yj0LplH/s=; b=cGhXacsx3F5gSdDOZHTboIctPH87XeNNhdNUQTUf5FOvkt6vKAqv8xZeXJ5AntBaqA Ac7oIVNXQKsqY2DTygMSsUdnrrtzD3s/qsvEFjAGJkLbI6RwPAUwTmrr2tt12CYwWxpN mxO1hS+99Ssc6lD4yxC5Qve4wb+UTPUdSOhD8hfXNgXcGS/faymR7VuXoU8K4OQkvKzK /IRZR20/ZD52A/lysQzYgR3a6vcRUu1NufcIyAnHJd9HmoxISOinkPhuqakj7MPkqZ9u w4CCRs9mRnJquiyI4IT88796e/frIC5gx6wrfm6O227oRUFWk+808drFxisxomFTKNH7 hrZA== X-Gm-Message-State: AG10YOQZWDCg+Lejj7vdggpztrLRGiGH/VzxzL8dk9yaTi1TRQION6XWVuhXGV26ezvMYg== X-Received: by 10.140.167.135 with SMTP id n129mr14715878qhn.73.1455459059792; Sun, 14 Feb 2016 06:10:59 -0800 (PST) Received: from localhost.localdomain ([187.180.187.217]) by smtp.gmail.com with ESMTPSA id d64sm9306677qgd.9.2016.02.14.06.10.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Feb 2016 06:10:59 -0800 (PST) From: Fabio Estevam To: dmitry.torokhov@gmail.com Cc: maitysanchayan@gmail.com, linux-input@vger.kernel.org, Fabio Estevam Subject: [PATCH] Input: colibri-vf50-ts - call iio_channel_release_all() in all error paths Date: Sun, 14 Feb 2016 12:10:49 -0200 Message-Id: <1455459049-5690-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 From: Fabio Estevam We need to make sure to call iio_channel_release_all() in all error paths of the probe function. Signed-off-by: Fabio Estevam --- Build-tested only. drivers/input/touchscreen/colibri-vf50-ts.c | 39 ++++++++++++++++++----------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/input/touchscreen/colibri-vf50-ts.c b/drivers/input/touchscreen/colibri-vf50-ts.c index 69828d0..67f8a17 100644 --- a/drivers/input/touchscreen/colibri-vf50-ts.c +++ b/drivers/input/touchscreen/colibri-vf50-ts.c @@ -279,9 +279,8 @@ static int vf50_ts_probe(struct platform_device *pdev) error = devm_add_action(dev, vf50_ts_channel_release, channels); if (error) { - iio_channel_release_all(channels); dev_err(dev, "Failed to register iio channel release action"); - return error; + goto channel_release; } num_adc_channels = 0; @@ -290,12 +289,15 @@ static int vf50_ts_probe(struct platform_device *pdev) if (num_adc_channels != COLI_TOUCH_REQ_ADC_CHAN) { dev_err(dev, "Inadequate ADC channels specified\n"); - return -EINVAL; + error = -EINVAL; + goto channel_release; } touchdev = devm_kzalloc(dev, sizeof(*touchdev), GFP_KERNEL); - if (!touchdev) - return -ENOMEM; + if (!touchdev) { + error = -ENOMEM; + goto channel_release; + } touchdev->pdev = pdev; touchdev->channels = channels; @@ -303,12 +305,13 @@ static int vf50_ts_probe(struct platform_device *pdev) error = of_property_read_u32(dev->of_node, "vf50-ts-min-pressure", &touchdev->min_pressure); if (error) - return error; + goto channel_release; input = devm_input_allocate_device(dev); if (!input) { dev_err(dev, "Failed to allocate TS input device\n"); - return -ENOMEM; + error = -ENOMEM; + goto channel_release; } platform_set_drvdata(pdev, touchdev); @@ -330,29 +333,31 @@ static int vf50_ts_probe(struct platform_device *pdev) error = input_register_device(input); if (error) { dev_err(dev, "Failed to register input device\n"); - return error; + goto channel_release; } error = vf50_ts_get_gpiod(dev, &touchdev->gpio_xp, "xp", GPIOD_OUT_LOW); if (error) - return error; + goto channel_release; error = vf50_ts_get_gpiod(dev, &touchdev->gpio_xm, "xm", GPIOD_OUT_LOW); if (error) - return error; + goto channel_release; error = vf50_ts_get_gpiod(dev, &touchdev->gpio_yp, "yp", GPIOD_OUT_LOW); if (error) - return error; + goto channel_release; error = vf50_ts_get_gpiod(dev, &touchdev->gpio_ym, "ym", GPIOD_OUT_LOW); if (error) - return error; + goto channel_release; touchdev->pen_irq = platform_get_irq(pdev, 0); - if (touchdev->pen_irq < 0) - return touchdev->pen_irq; + if (touchdev->pen_irq < 0) { + error = touchdev->pen_irq; + goto channel_release; + } error = devm_request_threaded_irq(dev, touchdev->pen_irq, NULL, vf50_ts_irq_bh, IRQF_ONESHOT, @@ -360,10 +365,14 @@ static int vf50_ts_probe(struct platform_device *pdev) if (error) { dev_err(dev, "Failed to request IRQ %d: %d\n", touchdev->pen_irq, error); - return error; + goto channel_release; } return 0; + +channel_release: + iio_channel_release_all(channels); + return error; } static const struct of_device_id vf50_touch_of_match[] = {