From patchwork Mon Jan 25 15:31:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitoj Kaur Chawla X-Patchwork-Id: 8109541 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D75E7BEEE5 for ; Mon, 25 Jan 2016 15:31:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0102920303 for ; Mon, 25 Jan 2016 15:31:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1ED1A202E9 for ; Mon, 25 Jan 2016 15:31:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755678AbcAYPb1 (ORCPT ); Mon, 25 Jan 2016 10:31:27 -0500 Received: from mail-pa0-f52.google.com ([209.85.220.52]:33506 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751913AbcAYPb1 (ORCPT ); Mon, 25 Jan 2016 10:31:27 -0500 Received: by mail-pa0-f52.google.com with SMTP id cy9so82445268pac.0; Mon, 25 Jan 2016 07:31:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=wuKnPcB3T1Bz2Z12UaJtoTsYCuCvHcC5WRC+hZBJryg=; b=J1LW5dqLk9R5MEp2ntP/ZtKR+EQqvtz/u6L9YJoe/vtv0mpp6Mj+S9KWGGLmP0oFgx wj08rKKjjy8nHR3lwDqB5bjEBVBSN/J+85hDbTw57jCw3qbB0d5WZiIOik0AQWh5iwKl fWI6mPazb3vW9xsVA2NuaAbekSZTlisPLvWjayoSzvq0NWLAp540ASn9WWj/rRG97kEq iMCZEksBYjIfpNC8p93ZFz9rHl0b+UpOShgRQsKknYE0x1Rbu6qliqwjqVBC9WcgK99Y TE1pPtBw0TsiSct+Yub0m7oSbe4odgos3huzg8hTIgvuXXNkZZL0OK9bfo1XZGzgAU2y ZtIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=wuKnPcB3T1Bz2Z12UaJtoTsYCuCvHcC5WRC+hZBJryg=; b=kehkjDU+vpWl7m3+JCFN7CUs53o2cebDD8Mnli6RFv3unFJ2QHruym0YJ2u/LaLeJw Sw990y/yid5BWw9tDOR4nCs8vUzftHb1+NKDRjOSCsMK4KorVp/V7b+uNTT3pbXuRZXw oWS4KBuzWxN7Osz0YsRSaLutNTd8MlGkx60dfKD7E1yCzpMWHDWF9SQD6ZMBv/t3UtL0 NOLvb+xCL4YRk5USm2SQ0TYJkHntl5rCueeU5gjA3m7X3KQ90kUW6h2uDE+xy/UQ+jod TUc6d899Vh7drNwRuwu07FKiE8js9fS6oDgkQ9P5jwxK3mHDIDVvUzrnxUrbQxlWWa0w Z/qA== X-Gm-Message-State: AG10YOTh29VsgkIi96xpPD4ZJDcGG1m80IWOfi6Cr8brkRz5zqkuDtiVKi2mRR6dk2G7YQ== X-Received: by 10.66.158.129 with SMTP id wu1mr26741738pab.146.1453735886415; Mon, 25 Jan 2016 07:31:26 -0800 (PST) Received: from localhost ([110.227.143.170]) by smtp.gmail.com with ESMTPSA id 3sm29428425pfb.64.2016.01.25.07.31.24 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 25 Jan 2016 07:31:25 -0800 (PST) Date: Mon, 25 Jan 2016 21:01:21 +0530 From: Amitoj Kaur Chawla To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: julia.lawall@lip6.fr Subject: [PATCH] input: keyboard: cap11xx: Add missing of_node_put Message-ID: <20160125153121.GA21093@amitoj-Inspiron-3542> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, 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 for_each_child_of_node performs an of_node_get on each iteration, so to break out of the loop an of_node_put is required. Found using Coccinelle. The semantic patch used for this is as follows: // @@ expression e; local idexpression n; @@ for_each_child_of_node(..., n) { ... when != of_node_put(n) when != e = n ( return n; | + of_node_put(n); ? return ...; ) ... } // --- drivers/input/keyboard/cap11xx.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/input/keyboard/cap11xx.c b/drivers/input/keyboard/cap11xx.c index 378db10..27cd7df 100644 --- a/drivers/input/keyboard/cap11xx.c +++ b/drivers/input/keyboard/cap11xx.c @@ -304,8 +304,10 @@ static int cap11xx_init_leds(struct device *dev, led->cdev.brightness = LED_OFF; error = of_property_read_u32(child, "reg", ®); - if (error != 0 || reg >= num_leds) - return -EINVAL; + if (error != 0 || reg >= num_leds) { + error = -EINVAL; + goto putchild; + } led->reg = reg; led->priv = priv; @@ -314,13 +316,17 @@ static int cap11xx_init_leds(struct device *dev, error = devm_led_classdev_register(dev, &led->cdev); if (error) - return error; + goto putchild; priv->num_leds++; led++; } return 0; + +putchild: + of_node_put(child); + return error; } #else static int cap11xx_init_leds(struct device *dev,