Skip to content

xfree86: Fix xf86Entities's xf86_platform_device pointing when udl screen unpluging.

ydc-dadada requested to merge ydc-dadada/xserver:work into master

When a computer has a usb controller and a discrete graphics card, and the device number of the pci bus where the usb controller is located is smaller than the discrete graphics card, Xorg will first identify the udl screen connected to the usb controller and then identify the discrete graphics card when it starts.

So the first member of xf86_platform_devices is the device information of the udl screen. And the second member is the information about the discrete graphics card.

Because the udl screen cannot be used as the main card, the xf86platformProbeDev function first points xf86Entities[0]-> to xf86_platform_devices[1]. Then point xf86Entities[1]-> to xf86_platform_devices[0].

When the udl screen is unplugged, the xf86_remove_platform_device function will reduce the members of the xf86_platform_devices array. At this time, there is only one member of xf86_platform_devices[], and xf86_platform_devices[0] saves the device information of the discrete graphics card.

But the address pointed to by xf86Entities[i]-> has not been changed. xf86Entities[1]-> = &xf86_platform_devices[0]; This makes xf86Entities[1] save the information of the discrete graphics card, but use the state of the udl screen. It makes it invalid to plug and unplug the udl screen again.

Merge request reports