Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5643431imm; Mon, 27 Aug 2018 01:25:28 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaBDNb8e2I154YlKOy7EEyHTQ6sTAdsvbuDGbg/lTIjCB5xFUgQLVBEWZUUeFQqBHXIgvmD X-Received: by 2002:a62:cc41:: with SMTP id a62-v6mr13185118pfg.131.1535358328461; Mon, 27 Aug 2018 01:25:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535358328; cv=none; d=google.com; s=arc-20160816; b=Ve6GyZKEkLaOYY6x8JnfTCK+eyefZMREBaNcwrl5R+KOiuoymKLSwnbizGxICbGWM0 /pDOj3a2nUt1AYvt4cRWQKid8m/JmEXeh6L1Zg9g8FOUqiEnamRxAT0FzTAGrQkpt6l7 DAI/U0TZwdWXwx0WKyl+m9+9L6JkFw6YknNA8Dg0eXaaNBX4W3hm/ztqlCQwUMbe2f3q JN8hgWGs5sBP9OFXjB8qQ3Bz8vJk+C3XhDsWNuW0EsJUVdVw5RzED1Zgb0dCz5vXBH4M RMLK5TcV4qX4ak52ywT/Zi9y0q20NYeCTKBClSPtSsT74OGgLixPvEYwwSsCjq9Ni4SL yeFg== 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=XJAxMJoFGwX/EPqhoE/MvooVBoBfkGRlL2+zPLHlEYQ=; b=mgHHPX4UDQY8G9JviqcWc7LfLIE2BCXtWVuJhSmyb8w+nPj1UhXtcDA7mmdqsq16Ny IAXKxhPxkWZXZFx8giQbiXJezxLaCYAo6Gv1FcNN+zs4+oBw5JJvgJL6lZr4G3G/ZlLp fM3xq+TYMGNPpeewh4g1GWcGugKzcAqcn7oD8ZXw+Vd0sHxbODQjlPaxUBgfpvpXUSpP TJVU3rl9nhQcu5UuuXmDF1QcEhxGqtXzJ5rbs2x99lyW8pRNLMWr80QItRCBZHNAzDeo tje4+lshkDcPGXsLGWkkjmo4zNIJm1I5Q4tsf9wdPdCLHPY0Y6rmAuvy4R2QaQxk6a0P Z4sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=l6moaF3S; 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 z14-v6si12140269pgl.466.2018.08.27.01.25.13; Mon, 27 Aug 2018 01:25:28 -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=l6moaF3S; 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 S1727145AbeH0MIN (ORCPT + 99 others); Mon, 27 Aug 2018 08:08:13 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:45982 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726826AbeH0MIM (ORCPT ); Mon, 27 Aug 2018 08:08:12 -0400 Received: by mail-lj1-f193.google.com with SMTP id u83-v6so11595338lje.12; Mon, 27 Aug 2018 01:22:34 -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=XJAxMJoFGwX/EPqhoE/MvooVBoBfkGRlL2+zPLHlEYQ=; b=l6moaF3SeKnYmGMxxc4LNizMQmraoLfJDZmj0RYnxZ77onB/clmSPCZi+SUCWmBZAU 0eUz4ENtQHWNBrY5XJBQ+I4iQtiorOX+5DCgTbh0Qra9qG1iYyuwhlkbEyQ/kBf7Yj8m DAO8hfj1HRjVqDTPNVLXI+OfMroB+xlIIVL4VTb8ExFRwqnnBWG0TsF+2U3tWixyGtRe 8g4BPiV2nP3UivITJmbKOLYuSUJKJjgtduBXbI9YAWfXSP/87PW4cjPU1qdd4nVt/+a9 G7w3s21IKW8XQLJwfUTG4DP9VHsaVLmQUBRvj2+g7VAMnEyqANq4S6f8HAZgRMj70P/Q kb7A== 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=XJAxMJoFGwX/EPqhoE/MvooVBoBfkGRlL2+zPLHlEYQ=; b=oXmrF8w48DluHha/1cpC26536Xt0pbq7oRVYOLH5sqM5xEynhO7VGCvfzLh0fuVp1l 3J35s85HSzn/UxT0h/uLAhEEBwfV9GPjliErv6Q8DQFbw4U6PBaXpPbnzIzCzy1X0SGn AfsZAjvjapk083Eb3K/XChjgTXByvUpIVBoqHNWqh/w8U159KSw31lWUwzyMAQk5cGNl LWk8Ht/M0rheiju/2fnB2gMXv530GC0h03aAvBd4t5YYSxH34NCZG9n8+4RCLB1A1Jcy rBQuCKi/V5N41GFint8T48QK/bpU5k4x1JLVZBya62l9ykZY12MObver2CuVrBfxnef+ ccsw== X-Gm-Message-State: APzg51De2ZfIhxTdreQb/Vbxa3+/Yz2RFiprOYnSXic14EN1V6T8f0x7 3KxXHTjM/H5O+P88syjkUbU= X-Received: by 2002:a2e:5053:: with SMTP id v19-v6mr6169841ljd.84.1535358153554; Mon, 27 Aug 2018 01:22:33 -0700 (PDT) Received: from xi.terra ([85.230.190.116]) by smtp.gmail.com with ESMTPSA id y17-v6sm1869165ljd.42.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-0005sr-1x; 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 , Florian Fainelli , "David S . Miller" Subject: [PATCH v2 6/9] net: bcmgenet: fix OF child-node lookup Date: Mon, 27 Aug 2018 10:21:50 +0200 Message-Id: <20180827082153.22537-7-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 mdio 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 node of the device being probed). Fixes: aa09677cba42 ("net: bcmgenet: add MDIO routines") Cc: stable # 3.15 Cc: Florian Fainelli Cc: David S. Miller Signed-off-by: Johan Hovold --- drivers/net/ethernet/broadcom/genet/bcmmii.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c index 5333274a283c..87fc65560ceb 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c @@ -333,7 +333,7 @@ static struct device_node *bcmgenet_mii_of_find_mdio(struct bcmgenet_priv *priv) if (!compat) return NULL; - priv->mdio_dn = of_find_compatible_node(dn, NULL, compat); + priv->mdio_dn = of_get_compatible_child(dn, compat); kfree(compat); if (!priv->mdio_dn) { dev_err(kdev, "unable to find MDIO bus node\n"); -- 2.18.0