• Johan Hovold's avatar
    mtd: rawnand: atmel: fix OF child-node lookup · 0aa6b111
    Johan Hovold authored
    commit 5d1e9c22 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: f88fc122 ("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: default avatarJohan Hovold <johan@kernel.org>
    Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    0aa6b111
nand-controller.c 63.4 KB