]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
dpaa2-switch: Fix device reference count leak in MAC endpoint handling
authorMa Ke <make24@iscas.ac.cn>
Thu, 17 Jul 2025 02:23:09 +0000 (10:23 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Aug 2025 08:51:27 +0000 (09:51 +0100)
commitbe4d2f9bb82c4cd72efcc9883ce17f5c3710c90c
treee7ec04ba932020348a12c0da7b4c9b835a8ea02d
parent7d59ff999d9e2015f6cb324b3234188b4443e9b6
dpaa2-switch: Fix device reference count leak in MAC endpoint handling

commit 96e056ffba912ef18a72177f71956a5b347b5177 upstream.

The fsl_mc_get_endpoint() function uses device_find_child() for
localization, which implicitly calls get_device() to increment the
device's reference count before returning the pointer. However, the
caller dpaa2_switch_port_connect_mac() fails to properly release this
reference in multiple scenarios. We should call put_device() to
decrement reference count properly.

As comment of device_find_child() says, 'NOTE: you will need to drop
the reference with put_device() after use'.

Found by code review.

Cc: stable@vger.kernel.org
Fixes: 84cba72956fd ("dpaa2-switch: integrate the MAC endpoint support")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Tested-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250717022309.3339976-3-make24@iscas.ac.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c