]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
sunvdc: Balance device refcount in vdc_port_mpgroup_check
authorMa Ke <make24@iscas.ac.cn>
Sat, 19 Jul 2025 07:58:56 +0000 (15:58 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:25:49 +0000 (16:25 +0200)
commit10a7e1a5cedd06de24a1602c5f462cfc5b1842e8
treef75a52f33a09d1f4423358c84c2a5fa7d72f1204
parent1a782fa32e644aa9fbae6c8488f3e61221ac96e1
sunvdc: Balance device refcount in vdc_port_mpgroup_check

commit 63ce53724637e2e7ba51fe3a4f78351715049905 upstream.

Using device_find_child() to locate a probed virtual-device-port node
causes a device refcount imbalance, as device_find_child() internally
calls get_device() to increment the device’s reference count before
returning its pointer. vdc_port_mpgroup_check() directly returns true
upon finding a matching device without releasing the reference via
put_device(). We should call put_device() to decrement refcount.

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: 3ee70591d6c4 ("sunvdc: prevent sunvdc panic when mpgroup disk added to guest domain")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Link: https://lore.kernel.org/r/20250719075856.3447953-1-make24@iscas.ac.cn
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/block/sunvdc.c