Configuring STM32 timer as frequency counter
Frequency counters can get complicated quick depending on the bandwidth you want and the clock speed of the internal clock as well as the size of the registers holding the clock ticks and the input ticks.

I mean it looks like it'll work but you should make sure that (1) the clock counter and the frequency counter are refreshed at the end of the sample (2) that neither will overflow during the sample (3) that the setup will give you the resolution you want and (4) that the MCU will make adjustments if the bandwidth is large enough where it'll overflow some of the time and/or dip very low. The first of which would cause incorrect results and the second of which would drastically reduce the accuracy at low Hz.