]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
PCI: tegra: Fix OF node reference leak
authorNishka Dasgupta <nishkadg.linux@gmail.com>
Wed, 24 Jul 2019 08:24:12 +0000 (13:54 +0530)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 16 Oct 2019 09:55:43 +0000 (11:55 +0200)
commit6c1a7a1786b66efe82aa2098d1a99c2a9945ee0d
tree3a7012c64a4d5a5d1e7776b18e997388931d324f
parent72e4f304fb4d2535ae32596c646e2d2952eb9f50
PCI: tegra: Fix OF node reference leak

BugLink: https://bugs.launchpad.net/bugs/1848274
[ Upstream commit 9e38e690ace3e7a22a81fc02652fc101efb340cf ]

Each iteration of for_each_child_of_node() executes of_node_put() on the
previous node, but in some return paths in the middle of the loop
of_node_put() is missing thus causing a reference leak.

Hence stash these mid-loop return values in a variable 'err' and add a
new label err_node_put which executes of_node_put() on the previous node
and returns 'err' on failure.

Change mid-loop return statements to point to jump to this label to
fix the reference leak.

Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
[lorenzo.pieralisi@arm.com: rewrote commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/pci/host/pci-tegra.c