From patchwork Sun Feb 19 12:07:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 9581571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E5A94604A0 for ; Sun, 19 Feb 2017 12:18:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECA01287A9 for ; Sun, 19 Feb 2017 12:18:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBAD52871A; Sun, 19 Feb 2017 12:18:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B45122871A for ; Sun, 19 Feb 2017 12:18:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751897AbdBSMSv (ORCPT ); Sun, 19 Feb 2017 07:18:51 -0500 Received: from smtp11.smtpout.orange.fr ([80.12.242.133]:26879 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751894AbdBSMSu (ORCPT ); Sun, 19 Feb 2017 07:18:50 -0500 Received: from localhost.localdomain ([92.140.226.155]) by mwinf5d22 with ME id mcAF1u0043MnwYU03cAF98; Sun, 19 Feb 2017 13:10:17 +0100 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 19 Feb 2017 13:10:17 +0100 X-ME-IP: 92.140.226.155 From: Christophe JAILLET To: jikos@kernel.org, benjamin.tissoires@redhat.com, briannorris@chromium.org, dianders@chromium.org Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] HID: i2c-hid: Fix error handling Date: Sun, 19 Feb 2017 13:07:59 +0100 Message-Id: <20170219120759.11162-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.9.3 X-Antivirus: avast! (VPS 170219-0, 19/02/2017), Outbound message X-Antivirus-Status: Clean Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to error handling in this function, it is likely that some resources should be freed before returning. Replace 'return ret', with 'goto err'. While at it, remove some spaces at the beginning of the lines to be more consistent. Fixes: ead0687fe304a ("HID: i2c-hid: support regulator power on/off") Signed-off-by: Christophe JAILLET Reviewed-by: Benjamin Tissoires --- drivers/hid/i2c-hid/i2c-hid.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index d5288f3fb5ee..1a57ac2d8524 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c @@ -1058,13 +1058,13 @@ static int i2c_hid_probe(struct i2c_client *client, } ihid->pdata.supply = devm_regulator_get(&client->dev, "vdd"); - if (IS_ERR(ihid->pdata.supply)) { - ret = PTR_ERR(ihid->pdata.supply); - if (ret != -EPROBE_DEFER) - dev_err(&client->dev, "Failed to get regulator: %d\n", - ret); - return ret; - } + if (IS_ERR(ihid->pdata.supply)) { + ret = PTR_ERR(ihid->pdata.supply); + if (ret != -EPROBE_DEFER) + dev_err(&client->dev, "Failed to get regulator: %d\n", + ret); + goto err; + } ret = regulator_enable(ihid->pdata.supply); if (ret < 0) {