Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5643415imm; Mon, 27 Aug 2018 01:25:26 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZMjSDsy20GYrMVLyna87J8spEKESwuJ2ZVc6oAY/vpjr4gcYG+jhSc/7E1C4BbUUWCB6Hi X-Received: by 2002:a63:8f48:: with SMTP id r8-v6mr11606318pgn.189.1535358326938; Mon, 27 Aug 2018 01:25:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535358326; cv=none; d=google.com; s=arc-20160816; b=NTef5ispDGmeHZFhm1/6mrxWrvGRuVd7/vsXHTV8AvvzwVE/WEasvpMjRk/C+kJE3A qoeAwPJlCbspPlV9cJqIvfVI8uKiuQTCQzJTwnSr1lDsgYW/6fov9FftlBmK2rY6JA+q BaMtViH1yCWHCGE+K9QWJpoFkgh3W/rPBUVxyou5YKUtoopi4z9paL0RWyHORIv8kqDU wocyCb+09WjiX8oRVzWOqGDfB4V/9v77FTzw1DF0DYiEFyq0DF7X6DNxpZEJm9Dp/EXB E7L9VD4UmkOCIfW4AD4GO7gyjxI4XPc1+xi5ijdEb7GlsbIWlkCH9cg9ngZWa+NYbF6i Q1AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=j9TEfnBOgeJPhtnrYYF91KbGFTGsSDrgCHOAcfWP4Mw=; b=sCEOX66+nVrgAuy4p5E0hdQ50U0Ck7gCZZQS3uGDyNdZedPw9rxAkMnomqY8exnUp8 zdxLVMlxrOx661h4qXD3KGSab8kqDbsH3EDTvrwOdDiV4cTssH34C0IaitYmPKVFmdZ+ W7oDHHi84FT3qg7XpsI8p1zIelPmbNuGbPXejpfmyA9ccTJ4VH4Vaipl0BnW+k8WuQec cflojOP065x3GnUB3zMwpY3H5XVdPNkjGZYlRYhepQ6EcI+3HtM8TnJrLzf62jCHOtAb LYhnkMPU9hRm4esbIytUuRSaBJTmY8ERJjIboUGnGXQNgqfJ1E+teZzZCXuya/l/IDn0 SkeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=sLL+l3Ef; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h127-v6si15265289pfg.292.2018.08.27.01.25.11; Mon, 27 Aug 2018 01:25:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=sLL+l3Ef; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727105AbeH0MIL (ORCPT + 99 others); Mon, 27 Aug 2018 08:08:11 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:33133 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726872AbeH0MIL (ORCPT ); Mon, 27 Aug 2018 08:08:11 -0400 Received: by mail-lj1-f194.google.com with SMTP id s12-v6so11620842ljj.0; Mon, 27 Aug 2018 01:22:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=j9TEfnBOgeJPhtnrYYF91KbGFTGsSDrgCHOAcfWP4Mw=; b=sLL+l3Ef7vuu98F2P2T9G3v9ADJLAmn98w8OEIxxEYESoYFK5cdNGA9DogEGtSz3Xq +CFyPZUw8zefxNxcJzNg0VF4B1zRPZ39A/TJQIIWb+aDSbSvblxMWqRMYmNnQv2SxV4q 8veoQkdQwpbdI6jE8jmEx37qWmdrEaZvw/F50yugVCN4vgumsh13txKY8kgD8o3g2AEv LkWWJlxQSp6XOuSjJUf54l0C9xNx5WREzC5KR9+3aVuax8fwyhzx5qJVk5IfAc1Os2eT XpkLirc5Pivx85B+HYkKYOO1f1U82eV9azJxH6ioRVz+csr4aWKMa8lx9vnzgBVsGu3L 5+Qg== 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 :in-reply-to:references; bh=j9TEfnBOgeJPhtnrYYF91KbGFTGsSDrgCHOAcfWP4Mw=; b=GveSClsfch34NhRLXqc0d0N8fIMJ6jjKd07ifhi+onqGXMkS2l12U0JTzGFDEiBk0K 2ngTwLbpOw6hinZU65EGfNgY+ti1MTqd3Ubf72ghtpum0thrjDDtx10YNYAgFwJqfJUL /feC7dO8ESHpBZdjKlcJOccYID7tJ7StIrAF9+ZPkwbBP16/6VxIqZztEF6KB3nqkKJs sIajEClYdUJnxu6u0s0ljqs5XdEw3D+gAgiygMOePrAsWz50LNJhu0bACIwmNgjntAfg whc+e65KXRdxjGDMd0z+Avy0UmlVT4dAZBPBDwS2FM19nVHhepcy9yAyoqPic1bOLIcP 98vQ== X-Gm-Message-State: APzg51CWW0joFxG+Q7G0xbeAY9qrdRJGhbLd2vhDQfOT6zg96WQQn5KK fF/aI0dwU26pBMFoL0FC3lFH5/mA X-Received: by 2002:a2e:3005:: with SMTP id w5-v6mr7559328ljw.20.1535358153014; Mon, 27 Aug 2018 01:22:33 -0700 (PDT) Received: from xi.terra ([85.230.190.116]) by smtp.gmail.com with ESMTPSA id f9-v6sm2649837ljf.9.2018.08.27.01.22.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Aug 2018 01:22:31 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.91) (envelope-from ) id 1fuCn7-0005t1-83; Mon, 27 Aug 2018 10:22:29 +0200 From: Johan Hovold To: Rob Herring , Greg Kroah-Hartman Cc: Frank Rowand , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable , Vincent Cuissard , Samuel Ortiz Subject: [PATCH v2 8/9] NFC: nfcmrvl_uart: fix OF child-node lookup Date: Mon, 27 Aug 2018 10:21:52 +0200 Message-Id: <20180827082153.22537-9-johan@kernel.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180827082153.22537-1-johan@kernel.org> References: <20180827082153.22537-1-johan@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the new of_get_compatible_child() helper to lookup the nfc child node instead of using of_find_compatible_node(), which searches the entire tree from a given start node and thus can return an unrelated (i.e. non-child) node. This also addresses a potential use-after-free (e.g. after probe deferral) as the tree-wide helper drops a reference to its first argument (i.e. the parent node). Fixes: e097dc624f78 ("NFC: nfcmrvl: add UART driver") Fixes: d8e018c0b321 ("NFC: nfcmrvl: update device tree bindings for Marvell NFC") Cc: stable # 4.2 Cc: Vincent Cuissard Cc: Samuel Ortiz Signed-off-by: Johan Hovold --- drivers/nfc/nfcmrvl/uart.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/nfc/nfcmrvl/uart.c b/drivers/nfc/nfcmrvl/uart.c index 91162f8e0366..9a22056e8d9e 100644 --- a/drivers/nfc/nfcmrvl/uart.c +++ b/drivers/nfc/nfcmrvl/uart.c @@ -73,10 +73,9 @@ static int nfcmrvl_uart_parse_dt(struct device_node *node, struct device_node *matched_node; int ret; - matched_node = of_find_compatible_node(node, NULL, "marvell,nfc-uart"); + matched_node = of_get_compatible_child(node, "marvell,nfc-uart"); if (!matched_node) { - matched_node = of_find_compatible_node(node, NULL, - "mrvl,nfc-uart"); + matched_node = of_get_compatible_child(node, "mrvl,nfc-uart"); if (!matched_node) return -ENODEV; } -- 2.18.0