]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
mtd: rawnand: atmel: fix OF child-node lookup
authorJohan Hovold <johan@kernel.org>
Mon, 27 Aug 2018 08:21:49 +0000 (10:21 +0200)
committerSultan Alsawaf <sultan.alsawaf@canonical.com>
Wed, 24 Jul 2019 15:44:50 +0000 (09:44 -0600)
commit5802d861bf1313a18711ad8cd5888338451380e3
tree5a1a9a04c364ed105eaa27a01dc083e24b83ef51
parentf17915d51250d48e7514a4150677e8d7b493416d
mtd: rawnand: atmel: fix OF child-node lookup

BugLink: https://bugs.launchpad.net/bugs/1836968
commit 5d1e9c2212ea6b4dd735e4fc3dd6279a365d5d10 upstream.

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 node of the device being probed).

While at it, also fix a related nfc-node reference leak.

Fixes: f88fc122cc34 ("mtd: nand: Cleanup/rework the atmel_nand driver")
Cc: stable <stable@vger.kernel.org> # 4.11
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Josh Wu <rainyfeeling@outlook.com>
Cc: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/mtd/nand/atmel/nand-controller.c