Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5985059imm; Mon, 27 Aug 2018 07:46:08 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbALae2uOXBS6oc4ITztHlvFAZlCwjFHO7Vy21L7+HHdDNwAneVz+ldvrozRf3ukCVnFExo X-Received: by 2002:a65:6550:: with SMTP id a16-v6mr12330509pgw.22.1535381167978; Mon, 27 Aug 2018 07:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535381167; cv=none; d=google.com; s=arc-20160816; b=XJWmaSuzUP1qjqJvBdLt7gQvrQs8RigOj1T8/WbQjzHjDXjKHUfDyeLbwJteHNwB/n 0Ts7FakGK0sL7/+0OJsDMVtR9QBxW8xN/lM2oOwRFKI/MBV5Kn6xMKxZ/sNRzEFOUU9i 8TLTfE8JE+9NRdvJNJFqDBrZfgamjO28vCSad7cshoscM0xeMBITs6OdD6OKnDjMdXBE WXOhfooXx/1omiD0OuRQ+F2nVv8txUwpi5xXQjnY9txq+pXVG99bRYDDWZztbj6n5fzP 7OGI+IQeUwdtapyeQTOk1z2oMETl3XN37SUaKUDp0Ui0bAQ3NIdce1kQjq75AejWfApP LORg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=7Zbg0l+zPmcIWKxIIdhrxwqbyKJ1VUIkhHVxV2FVNnM=; b=qFxqppulrV9O1hayV2eumRaJwDMWu5pY7XgUj2uAzGx58YYAO0ir67uu/ue5eH56kH jPoB7Z+g79J7xFi02vlwVdOmk5WlQiRPq65VBj/DnilqMbyBgq+hTL2SJOvPadpXmPHd lGS+8C/B9masRQ1mYBwLAqYEgJcnZSHRUEk3dTJAnDPoE5B8RfkWFpFMTR1Rc2sC/0n5 XKIPf/jGKSeKgbVUryBU1/xqGpDnm0Pe1QkB2cFZ6ziEzpBqjV5PqPbrVf7xyR/IIuzf X0n3dH2j6fdseyOgszZVeH9tjqaAsbyBK7iNnhDZZ7E5SuY7ximRke+e2c5bqEnS7UCO G5HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YmQ3XFZS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 184-v6si15203192pfe.249.2018.08.27.07.45.52; Mon, 27 Aug 2018 07:46:07 -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=pass header.i=@linaro.org header.s=google header.b=YmQ3XFZS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727053AbeH0Sbm (ORCPT + 99 others); Mon, 27 Aug 2018 14:31:42 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:34606 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726900AbeH0Sbm (ORCPT ); Mon, 27 Aug 2018 14:31:42 -0400 Received: by mail-it0-f67.google.com with SMTP id x79-v6so11861592ita.1 for ; Mon, 27 Aug 2018 07:44:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=7Zbg0l+zPmcIWKxIIdhrxwqbyKJ1VUIkhHVxV2FVNnM=; b=YmQ3XFZSCaB+Zs9Qx+O4u1zTyD7oQPwtjHOR9DJcEOWM5gJOVZ2Ucd2+s+cv88kUA1 NERsoA7RSqp6Rq7S3uy4fK7PAkvt4wqZjaPchhIM0e0SzHlXIPOVhgzw6rcA779H+wbs MV999QInIgdx4eHn9rHGNIEqCDD9hAR/LK1fY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=7Zbg0l+zPmcIWKxIIdhrxwqbyKJ1VUIkhHVxV2FVNnM=; b=o+Go6hsw68sVrs+rXUCx9jrQg+iS8l6e/EcfvZ6IlNGVV23v+egdefrr4kNtsuRP4E RdyBaqMJW6HIBveZPof+1dnEjP42UBZnIuGTrn/ruHzgDr4aT8om0tmMzmclYjT6NMRj PsIYcmuM5uiszR6E0vzQ/2jvC4pPJxmrK3bGT7ElZmZ2o3lZ9oquZ0VJ1vafar7hCEjt yLfkYX0nIBXFvIU2enZEjbfWPcV8yR4BnifwtEdNVU6OeMQgoSQbQwxyjpUtE56yKuss s307iFRVHWRJhkxSLYlph4CdtjeTXIzQKWnkmH8ZH9fuE3po33EFq4HWiEc8+5xqP282 8Dyw== X-Gm-Message-State: APzg51CH8QhF0+yjG8XpK0iQPc4jpAleajnEu1pNm7Q2e9ZSzrH8wvLr az3dW475uWToM1YWAtNvvokRPDu1ImxgN0W5YtRb2g== X-Received: by 2002:a24:a388:: with SMTP id p130-v6mr6854659ite.146.1535381085735; Mon, 27 Aug 2018 07:44:45 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:2b03:0:0:0:0:0 with HTTP; Mon, 27 Aug 2018 07:44:44 -0700 (PDT) In-Reply-To: <20180827082153.22537-5-johan@kernel.org> References: <20180827082153.22537-1-johan@kernel.org> <20180827082153.22537-5-johan@kernel.org> From: Ulf Hansson Date: Mon, 27 Aug 2018 16:44:44 +0200 Message-ID: Subject: Re: [PATCH v2 4/9] mmc: meson-mx-sdio: fix OF child-node lookup To: Johan Hovold Cc: Rob Herring , Greg Kroah-Hartman , Frank Rowand , DTML , Linux Kernel Mailing List , stable , Carlo Caione , Martin Blumenstingl Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27 August 2018 at 10:21, Johan Hovold wrote: > Use the new of_get_compatible_child() helper to lookup the slot 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). > > While at it, also fix up the related slot-node reference leak. > > Fixes: ed80a13bb4c4 ("mmc: meson-mx-sdio: Add a driver for the Amlogic Meson8 and Meson8b SoCs") > Cc: stable # 4.15 > Cc: Carlo Caione > Cc: Martin Blumenstingl > Cc: Ulf Hansson > Acked-by: Martin Blumenstingl > Signed-off-by: Johan Hovold Acked-by: Ulf Hansson Kind regards Uffe > --- > drivers/mmc/host/meson-mx-sdio.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/mmc/host/meson-mx-sdio.c b/drivers/mmc/host/meson-mx-sdio.c > index 09cb89645d06..2cfec33178c1 100644 > --- a/drivers/mmc/host/meson-mx-sdio.c > +++ b/drivers/mmc/host/meson-mx-sdio.c > @@ -517,19 +517,23 @@ static struct mmc_host_ops meson_mx_mmc_ops = { > static struct platform_device *meson_mx_mmc_slot_pdev(struct device *parent) > { > struct device_node *slot_node; > + struct platform_device *pdev; > > /* > * TODO: the MMC core framework currently does not support > * controllers with multiple slots properly. So we only register > * the first slot for now > */ > - slot_node = of_find_compatible_node(parent->of_node, NULL, "mmc-slot"); > + slot_node = of_get_compatible_child(parent->of_node, "mmc-slot"); > if (!slot_node) { > dev_warn(parent, "no 'mmc-slot' sub-node found\n"); > return ERR_PTR(-ENOENT); > } > > - return of_platform_device_create(slot_node, NULL, parent); > + pdev = of_platform_device_create(slot_node, NULL, parent); > + of_node_put(slot_node); > + > + return pdev; > } > > static int meson_mx_mmc_add_host(struct meson_mx_mmc_host *host) > -- > 2.18.0 >