From patchwork Mon Nov 13 10:27:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 10055513 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 AAE386029B for ; Mon, 13 Nov 2017 10:28:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75F782934E for ; Mon, 13 Nov 2017 10:28:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6ADE229361; Mon, 13 Nov 2017 10:28:10 +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_SIGNED, 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 107042934E for ; Mon, 13 Nov 2017 10:28:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751434AbdKMK14 (ORCPT ); Mon, 13 Nov 2017 05:27:56 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:56343 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751313AbdKMK1z (ORCPT ); Mon, 13 Nov 2017 05:27:55 -0500 Received: by mail-lf0-f67.google.com with SMTP id g35so3420173lfi.13; Mon, 13 Nov 2017 02:27:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=gCooSwcsN5ZKsS62ZlsoTKH89Y72SMj8ctjb3uSA/Mg=; b=TWePc+O2qodpgDfQh9xWHzSwBTLaVHVCeJX8YzPPDUzcbqLhzKg3H3g5MuV5spdyVo o8sm8TOIY/u7Bo0nRVqJHDmAwu2oFKD8B2BfNLdDFEbBMJRFBabbo/DzcT2lXyj0ge42 morgYXFBrDoVXQrxDuYaBlA0dlzBEWTOEXQQku6me7EjrHvU20zBBHGO9CWAgUE+V65t XjGEK4WYYYvQ1mmi1KE5oIKIbu3ulFwtnSsy0BO/xoI+BaJYfInoRxWZizSgpc25hbKz f8h3PHcWRpM6GVvTUGE8SlBQmDyIuW8pizSuDNLF1ELd58nq3J8Egu3YAfjAlsL6aM4U EGdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=gCooSwcsN5ZKsS62ZlsoTKH89Y72SMj8ctjb3uSA/Mg=; b=q1NJb+GU7O9bjJdxhHUNMcx1RgJ8z3ohVUhkhM+NIPWPx4blyUvhrFYbYGeYtXEjxX wXd7CpPHO2SmJEt+wsfQoP6MzWnC9hdHiBWYlyYg2jJRNS2jyVf+I4Pkl27s7CDhZi0J jULI5SrQoiG+6XApIvodbVIoQGASK+hZz3GQMtc4KHCcdTckf6SA3N0vFRAAmSyA06cI pssKsmIa0KXJSLDMtDZ49dI1juJth209pCHkMsy/Q4GKlXUkt9MZWwXUxuAkrXLzj9C2 BrmG5kZshCNOdANzJ1MRHRY+BkSTCHcF28jnIojj0Mnou2b8oWwc2emgr0BXVco1HITJ ZvBg== X-Gm-Message-State: AJaThX52WXjNtDZVrQrSxenXvEj8RtWnzKCpZWe8sZk/bTUSjjlRqw6Z sL/VGTFA80E2R3iquZMF90A= X-Google-Smtp-Source: AGs4zMaUSdKY47e0/irklZ4sFftWCX0RFPW8u3cPudCgeL+uoJjkrEXPhmueSZZzhA5n6hQeIrm1Jg== X-Received: by 10.46.68.73 with SMTP id r70mr3213426lja.174.1510568873879; Mon, 13 Nov 2017 02:27:53 -0800 (PST) Received: from xi.terra (c-c0bae655.07-184-6d6c6d4.cust.bredbandsbolaget.se. [85.230.186.192]) by smtp.gmail.com with ESMTPSA id m18sm647437lje.21.2017.11.13.02.27.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Nov 2017 02:27:53 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1eEByB-0002WO-J9; Mon, 13 Nov 2017 11:27:59 +0100 From: Johan Hovold To: Nicolas Ferre Cc: Bartlomiej Zolnierkiewicz , Alexandre Belloni , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Johan Hovold , stable , Jean-Christophe PLAGNIOL-VILLARD Subject: [PATCH] video: fbdev: atmel_lcdfb: fix display-timings lookup Date: Mon, 13 Nov 2017 11:27:19 +0100 Message-Id: <20171113102719.9634-1-johan@kernel.org> X-Mailer: git-send-email 2.15.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children. To make things worse, the parent display node was also prematurely freed. Note that the display and timings node references are never put after a successful dt-initialisation so the nodes would leak on later probe deferrals and on driver unbind. Fixes: b985172b328a ("video: atmel_lcdfb: add device tree suport") Cc: stable # 3.13 Cc: Jean-Christophe PLAGNIOL-VILLARD Signed-off-by: Johan Hovold --- drivers/video/fbdev/atmel_lcdfb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/atmel_lcdfb.c b/drivers/video/fbdev/atmel_lcdfb.c index e06358da4b99..3dee267d7c75 100644 --- a/drivers/video/fbdev/atmel_lcdfb.c +++ b/drivers/video/fbdev/atmel_lcdfb.c @@ -1119,7 +1119,7 @@ static int atmel_lcdfb_of_init(struct atmel_lcdfb_info *sinfo) goto put_display_node; } - timings_np = of_find_node_by_name(display_np, "display-timings"); + timings_np = of_get_child_by_name(display_np, "display-timings"); if (!timings_np) { dev_err(dev, "failed to find display-timings node\n"); ret = -ENODEV; @@ -1140,6 +1140,12 @@ static int atmel_lcdfb_of_init(struct atmel_lcdfb_info *sinfo) fb_add_videomode(&fb_vm, &info->modelist); } + /* + * FIXME: Make sure we are not referencing any fields in display_np + * and timings_np and drop our references to them before returning to + * avoid leaking the nodes on probe deferral and driver unbind. + */ + return 0; put_timings_node: