bus: fsl-mc: Fix potential double device reference in fsl_mc_get_endpoint()
authorMa Ke <make24@iscas.ac.cn>
Thu, 17 Jul 2025 02:23:07 +0000 (10:23 +0800)
committerJakub Kicinski <kuba@kernel.org>
Sat, 19 Jul 2025 00:13:50 +0000 (17:13 -0700)
commitbddbe13d36a02d5097b99cf02354d5752ad1ac60
tree56c56a89fc6df8e99f885c8e3d80706cd035203c
parent6832a9317eee280117cd695fa885b2b7a7a38daf
bus: fsl-mc: Fix potential double device reference in fsl_mc_get_endpoint()

The fsl_mc_get_endpoint() function may call fsl_mc_device_lookup()
twice, which would increment the device's reference count twice if
both lookups find a device. This could lead to a reference count leak.

Found by code review.

Cc: stable@vger.kernel.org
Fixes: 1ac210d128ef ("bus: fsl-mc: add the fsl_mc_get_endpoint function")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Tested-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Fixes: 8567494cebe5 ("bus: fsl-mc: rescan devices if endpoint not found")
Link: https://patch.msgid.link/20250717022309.3339976-1-make24@iscas.ac.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/bus/fsl-mc/fsl-mc-bus.c