]> git.baikalelectronics.ru Git - kernel.git/commit
thunderbolt: fix memory leak of object sw
authorColin Ian King <colin.king@canonical.com>
Fri, 20 Dec 2019 22:05:26 +0000 (22:05 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jan 2020 14:37:41 +0000 (15:37 +0100)
commitf135658e5af319d1df59e6683aa59dabbf163f3b
tree27e982aed465eff3502b9a44c2ed20fa66ca9ab1
parentb2c507dfe5a4bb38cd206868d6093bdb7f4c5331
thunderbolt: fix memory leak of object sw

In the case where the call tb_switch_exceeds_max_depth is true
the error reurn path leaks memory in sw.  Fix this by setting
the return error code to -EADDRNOTAVAIL and returning via the
error exit path err_free_sw_ports to free sw. sw has been kzalloc'd
so the free of the NULL sw->ports is fine.

Addresses-Coverity: ("Resource leak")
Fixes: 469e0ed31b42 ("thunderbolt: Add initial support for USB4")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Link: https://lore.kernel.org/r/20191220220526.11307-1-colin.king@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/thunderbolt/switch.c