From patchwork Fri Oct 28 23:14:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9402819 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 C3302601C0 for ; Fri, 28 Oct 2016 23:15:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B08872A900 for ; Fri, 28 Oct 2016 23:15:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A35AF2A904; Fri, 28 Oct 2016 23:15:22 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 46DDA2A8FD for ; Fri, 28 Oct 2016 23:15:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030563AbcJ1XOy (ORCPT ); Fri, 28 Oct 2016 19:14:54 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33246 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1034432AbcJ1XOu (ORCPT ); Fri, 28 Oct 2016 19:14:50 -0400 Received: by mail-pf0-f193.google.com with SMTP id i85so2363169pfa.0; Fri, 28 Oct 2016 16:14:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4y391r0TT83OMqs3Bp4oUEJLk3PSRyCUVxAJ0mVhzQg=; b=WRTG3dOP7fGIgE7IUVHXwTqgIiT5xNna393yxheSjy9OU8Z8EVs2EfsSrhLB79qZiM irBNCJwbzsS2rhATcBlDq2w/ajK0fpoYwcMPUbjVApcp/66ataup4NHVTJyM9jiBeHj6 hze+NQieU9wikeCqrr49lRUwZXi4xLkW3Q8YebwL/p3InTfCWx/Qd+YQoVTSqhOFxUI6 eSjMta7MagOJCrQBcEW1v0fHcZz6X7TLHVx5zlXFUlgAJussg6o/1GAcuS8j72XMO+pm yPE6RGEoq7ySd57h0ocd+h/q4EPoQ39TO/aMdlj2H5LF1dGbjKfy36Wa0nRn7SzzfJ3v Nkvg== 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:in-reply-to :references; bh=4y391r0TT83OMqs3Bp4oUEJLk3PSRyCUVxAJ0mVhzQg=; b=bb7vcknjo3lkW1AYufB61qFpz5zGLQa2QIQmC28jqTSsXGH2fTE5mFdn5G0mpvwle8 xZ+FTiha/Z9voJwnaOdE3gadtvKtjoxcs1lztIGUG88XJ92hOJIly3uttkZBxOY6gHi4 dneRBmBHA+bpQzCtPn6vDlNJGL4EcDDkdXqcWJT5Uw/Nz/iG4OPD+pxC5jVEOKlWO0jK +sQqQByRujW1gcTOcp8JZl1WGq6w9rbJyohs/tJBv1JOYKke/fEtR8MVhX9fRulLDPCb 2/k80w3iCmqQ5W4AFYLMt1yaAOvl4mH9EedVeLkM+UD5EG4ZgliB1KZtEW8zv9G/anqu EuUg== X-Gm-Message-State: ABUngveuAqRqmN/cRPJhXa1M3GZacuW6H945KytWVX9ZzAl6uCldNaObx0e/SQjPrvDeVg== X-Received: by 10.99.181.10 with SMTP id y10mr23917328pge.161.1477696489720; Fri, 28 Oct 2016 16:14:49 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([172.22.152.21]) by smtp.gmail.com with ESMTPSA id a66sm21198241pfe.51.2016.10.28.16.14.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Oct 2016 16:14:49 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Linus Walleij , Hans de Goede , Mika Westerberg , Geert Uytterhoeven , linux-kernel@vger.kernel.org Subject: [PATCH 4/6] Input: gpio_keys - fix leaking DT node references Date: Fri, 28 Oct 2016 16:14:42 -0700 Message-Id: <1477696485-6995-4-git-send-email-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1477696485-6995-1-git-send-email-dmitry.torokhov@gmail.com> References: <1477696485-6995-1-git-send-email-dmitry.torokhov@gmail.com> 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 for_each_available_child_of_node(node, pp) takes reference to 'pp' and drops it when attempting next iteration. However if we exit the loop early we need to drop the reference ourselves. Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/gpio_keys.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 8f7c20b..d75a25c 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -659,6 +659,7 @@ gpio_keys_get_devtree_pdata(struct device *dev) dev_err(dev, "Failed to get gpio flags, error: %d\n", error); + of_node_put(pp); return ERR_PTR(error); } } else { @@ -669,12 +670,14 @@ gpio_keys_get_devtree_pdata(struct device *dev) if (!gpio_is_valid(button->gpio) && !button->irq) { dev_err(dev, "Found button without gpios or irqs\n"); + of_node_put(pp); return ERR_PTR(-EINVAL); } if (of_property_read_u32(pp, "linux,code", &button->code)) { dev_err(dev, "Button without keycode: 0x%x\n", button->gpio); + of_node_put(pp); return ERR_PTR(-EINVAL); }