Patch "phy: tegra: fix device-tree node lookups" has been added to the 4.14-stable tree
Subsystems (4)
This is a note to let you know that I've just added the patch titled
phy: tegra: fix device-tree node lookups
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
phy-tegra-fix-device-tree-node-lookups.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
046046737bd35bed047460f080ea47e186be731eMon Sep 17 00:00:00 2001
From: Johan Hovold <[email protected]>
Date: Wed, 15 Nov 2017 10:43:16 +0100
Subject: phy: tegra: fix device-tree node lookups
From: Johan Hovold <[email protected]>
commit 046046737bd35bed047460f080ea47e186be731e upstream.
Fix child-node lookups during probe, which ended up searching the whole device tree depth-first starting at the parents rather than just matching on their children.
To make things worse, some parent nodes could end up being being prematurely freed (by tegra_xusb_pad_register()) as of_find_node_by_name() drops a reference to its first argument.
--- drivers/phy/tegra/xusb.c | 60 +++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 30 deletions(-)
drivers/phy/tegra/xusb.c +30 -30
@@ -75,14 +75,14 @@ MODULE_DEVICE_TABLE(of, tegra_xusb_padctstatic struct device_node *tegra_xusb_find_pad_node (struct tegra_xusb_padctl *padctl,const char *name) { -/* -* of_find_node_by_name() drops a reference, so make sure to grab one. -*/ -struct device_node *np =of_node_get (padctl->dev->of_node); +struct device_node *pads, *np; - np =of_find_node_by_name (np,"pads" ); -if (np) - np =of_find_node_by_name (np, name); + pads =of_get_child_by_name (padctl->dev->of_node,"pads" ); +if (!pads) +return NULL ; + + np =of_get_child_by_name (pads, name); +of_node_put (pads);return np; }
@@ -90,16 +90,16 @@ tegra_xusb_find_pad_node(struct tegra_xustatic struct device_node *tegra_xusb_pad_find_phy_node (struct tegra_xusb_pad *pad,unsigned int index) { -/* -* of_find_node_by_name() drops a reference, so make sure to grab one. -*/ -struct device_node *np =of_node_get (pad->dev.of_node); +struct device_node *np, *lanes; - np =of_find_node_by_name (np,"lanes" ); -if (!np) + lanes =of_get_child_by_name (pad->dev.of_node,"lanes" ); +if (!lanes)return NULL ; -return of_find_node_by_name (np, pad->soc->lanes[index].name); + np =of_get_child_by_name (lanes, pad->soc->lanes[index].name); +of_node_put (lanes); + +return np; } static int
@@ -195,7 +195,7 @@ int tegra_xusb_pad_register(struct tegraunsigned int i;int err; - children =of_find_node_by_name (pad->dev.of_node,"lanes" ); + children =of_get_child_by_name (pad->dev.of_node,"lanes" );if (!children)return -ENODEV ;
@@ -444,21 +444,21 @@ static struct device_node * tegra_xusb_find_port_node(struct tegra_xusb_padctl *padctl, const char *type, unsigned int index) { - /* - * of_find_node_by_name() drops a reference, so make sure to grab one. - */ - struct device_node *np = of_node_get(padctl->dev->of_node); + struct device_node *ports, *np; +char *name; + + ports =of_get_child_by_name (padctl->dev->of_node,"ports" ); +if (!ports) +return NULL ; - np =of_find_node_by_name (np,"ports" ); -if (np) { -char *name; - - name =kasprintf (GFP_KERNEL ,"%s-%u" , type, index); -if (!name) -return ERR_PTR (-ENOMEM ); - np =of_find_node_by_name (np, name); -kfree (name); + name =kasprintf (GFP_KERNEL ,"%s-%u" , type, index); +if (!name) { +of_node_put (ports); +return ERR_PTR (-ENOMEM ); } + np =of_get_child_by_name (ports, name); +kfree (name); +of_node_put (ports);return np; }
@@ -847,7 +847,7 @@ static void tegra_xusb_remove_ports(strustatic int tegra_xusb_padctl_probe (struct platform_device *pdev) { -struct device_node *np =of_node_get (pdev->dev.of_node); +struct device_node *np = pdev->dev.of_node;const struct tegra_xusb_padctl_soc *soc;struct tegra_xusb_padctl *padctl;const struct of_device_id *match;
@@ -855,7 +855,7 @@ static int tegra_xusb_padctl_probe(strucint err;/* for backwards compatibility with old device trees */ - np =of_find_node_by_name (np,"pads" ); + np =of_get_child_by_name (np,"pads" );if (!np) {dev_warn (&pdev->dev,"deprecated DT, using legacy driver\n" );return tegra_xusb_padctl_legacy_probe (pdev);
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/asoc-twl4030-fix-child-node-lookup.patch queue-4.14/usb-serial-qcserial-add-sierra-wireless-em7565.patch queue-4.14/usb-chipidea-msm-fix-ulpi-node-lookup.patch queue-4.14/usb-serial-ftdi_sio-add-id-for-airbus-ds-p8gr.patch queue-4.14/usb-serial-option-adding-support-for-yuga-clm920-nc5.patch queue-4.14/usb-serial-option-add-support-for-telit-me910-pid-0x1101.patch queue-4.14/phy-tegra-fix-device-tree-node-lookups.patch queue-4.14/asoc-da7218-fix-fix-child-node-lookup.patch