Skip to content

Commit 7fcb80c

Browse files
Ma Kekawasaki
authored andcommitted
sunvdc: Balance device refcount in vdc_port_mpgroup_check
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: [email protected] Fixes: 3ee7059 ("sunvdc: prevent sunvdc panic when mpgroup disk added to guest domain") Signed-off-by: Ma Ke <[email protected]>
1 parent 87bbbbc commit 7fcb80c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/block/sunvdc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,8 +957,10 @@ static bool vdc_port_mpgroup_check(struct vio_dev *vdev)
957957
dev = device_find_child(vdev->dev.parent, &port_data,
958958
vdc_device_probed);
959959

960-
if (dev)
960+
if (dev) {
961+
put_device(dev);
961962
return true;
963+
}
962964

963965
return false;
964966
}

0 commit comments

Comments
 (0)