I am thinking about a relatively cheap and simple protection against USB reverse connection/reverse polarity. At the moment I am thinking about P-channel MOSFET, with the drain directed towards the USB socket. I heard that TVS diodes can also, in addition to protection against ESD, prevent reverse polarity, but I would not be able to choose them exactly. Pins D + and D- are connected via resistors to the STM microcontroller.
As it is a Type P MOSFET, the gate being low will cause the transistor to conduct from the drain to the source. I predict that when the USB plug is plugged inversely, the MOSFET gate will be high and the MOSFET will shut off, preventing damage to the receiving circuit.
But these are only my modest theoretical considerations, and I would like to ask if I have not made a logical error here or if something is not ok from a practical point of view.