]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
media: v4l2-core: Fix a potential resource leak in v4l2_fwnode_parse_link()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Wed, 14 Jun 2023 18:31:05 +0000 (20:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Sep 2023 10:22:43 +0000 (12:22 +0200)
commitcaf058833b6f3fe7beabf738110f79bb987c8fff
tree22fad4cff8aa43926bf8a192c918c2afeb7e8ff2
parent711e9e44f6c434ff4b279d3cbc9988034216de26
media: v4l2-core: Fix a potential resource leak in v4l2_fwnode_parse_link()

[ Upstream commit d7b13edd4cb4bfa335b6008ab867ac28582d3e5c ]

If fwnode_graph_get_remote_endpoint() fails, 'fwnode' is known to be NULL,
so fwnode_handle_put() is a no-op.

Release the reference taken from a previous fwnode_graph_get_port_parent()
call instead.

Also handle fwnode_graph_get_port_parent() failures.

In order to fix these issues, add an error handling path to the function
and the needed gotos.

Fixes: ca50c197bd96 ("[media] v4l: fwnode: Support generic fwnode for parsing standardised properties")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/v4l2-core/v4l2-fwnode.c